Go Back   RunUO - Ultima Online Emulation > RunUO > Server Support on Mono

Server Support on Mono Forum dedicated to RunUO 2.0 on Mono.

Reply
 
Thread Tools Display Modes
Old 12-01-2007, 10:09 PM   #1 (permalink)
Forum Expert
 
Cheetah2003's Avatar
 
Join Date: Jun 2006
Location: Laramie, Wyoming
Age: 36
Posts: 354
Send a message via ICQ to Cheetah2003 Send a message via AIM to Cheetah2003 Send a message via MSN to Cheetah2003 Send a message via Yahoo to Cheetah2003
Default MultiTextWriter?

Hey... not sure if this is a mono only thing, but MultiTextWriter doesn't seem to be properly catching all possible WriteLines? I dunno, everything is going into the Console.Log (I changed the core to always log to a file.)

But with my code to add datetime to each line just doesnt seem to be catching every newline. The FileLogger class doesn't catch them all either.

Anyone got an idea? Here's my revised MultiTextWriter class:

Code:
	public class MultiTextWriter : TextWriter
	{
		private List<TextWriter> m_Streams;
		private bool m_NewLineNeeded = true;

		public MultiTextWriter( params TextWriter[] streams )
		{
			m_Streams = new List<TextWriter>( streams );

			if( m_Streams.Count < 0 )
				throw new ArgumentException( "You must specify at least one stream." );
		}

		public void Add( TextWriter tw )
		{
			m_Streams.Add( tw );
		}

		public void Remove( TextWriter tw )
		{
			m_Streams.Remove( tw );
		}

		public override void Write( char ch )
		{
			if (m_NewLineNeeded)
			{
				for (int i = 0; i < m_Streams.Count; i++)
					m_Streams[i].Write(String.Format("[{0}] ", DateTime.Now.ToString("MMM d HH:mm")));
				m_NewLineNeeded = false;
			}
			for( int i = 0; i < m_Streams.Count; i++ )
				m_Streams[i].Write( ch );
		}

		public override void WriteLine( string line )
		{
			for (int i = 0; i < m_Streams.Count; i++)
			{
				if (m_NewLineNeeded)
					m_Streams[i].WriteLine(String.Format("[{0}] {1}", DateTime.Now.ToString("MMM d HH:mm"), line));
				else
					m_Streams[i].WriteLine(line);
			}
			m_NewLineNeeded = true;
		}

		public override void WriteLine( string line, params object[] args )
		{
			WriteLine( String.Format( line, args ) );
		}

		public override void WriteLine(char[] line)
		{
			WriteLine(String.Format("{0}", line));
		}

		public override void WriteLine(char ch)
		{
			WriteLine(String.Format("{0}", ch));
		}

		public override void WriteLine(object o)
		{
			WriteLine(o.ToString());
		}

		public override Encoding Encoding
		{
			get { return Encoding.Default; }
		}
	}
Here's a sample of my console output:

Code:
[/home/cheetah/runuo] luxray:40> mono RunUO.exe
[Dec 1 20:05] RunUO - [www.runuo.com] Version 2.0, Build 2891.35960
[Dec 1 20:05] Core: Running on .NET Framework Version 2.0.50727
Core: Unix environment detected
[Dec 1 20:05] Using: [CoreScripts] Version 1.4.1445.16106
[Dec 1 20:05] Scripts: Compiling C# scripts...done (cached)
[Dec 1 20:05] Scripts: Compiling VB.NET scripts...no files found.
[Dec 1 20:05] Scripts: Verifying...done (4498 items, 1024 mobiles)
XMLServerOptions.cs -- Version 1.0
Loading configuration file Data/ServerConfig.xml...
Configuration loaded!
[Dec 1 20:05] FSATS XML Configuration -- Version 1.0
Loading FSATS configuration from Data/FSATSConfig.xml...
FSATS configuration loaded.
[Dec 1 20:05] Rails 1.0 -- Waiting for World Load
[Dec 1 20:05] Regions: Loading...done
[Dec 1 20:05] World: Loading...done (462925 items, 40405 mobiles) (105.30 seconds)
Onsite Dueling System: DuelPoints loaded.
[Dec 1 20:07] Xanthos.Utilities.ConfigParser failed.
[Dec 1 20:07] Loading XmlDialog configuration
4 settings processed
TransferServer version 1.05 listening on port 2591
Remote Admin 1.0.1.6 -- Admin Channel on port 2592.
QuestLogger: No data to cache.
[Dec 1 20:07] UO Architect Server for RunUO 2.0 is currently disabled.
Loading XmlSpawner configuration
8 settings processed
Account Purge v1.0 Initialized -- Next Purge time in: 08:52:41.0323660
Listening: 127.0.0.1:2593
Listening: 10.0.0.6:2593
Time System: Version 2.0.5 loading...
[Dec 1 20:07] Time System: Logging is enabled.
[Dec 1 20:07] Time System: Calculated managed lights list and found 1127 lights.
[Dec 1 20:07] Time System: Loading complete.
[Dec 1 20:07] Time System: It is 4:48 AM on the 20th of January, 6. The moon is new.
[Dec 1 20:07] Rails 1.0 -- Initializing rails
[Dec 1 20:07] Rails 1.0 -- Initialized 0 NPCs with rails
__________________
Take a walk on The Wild side.
Cheetah2003 is offline   Reply With Quote
Old 12-03-2007, 06:01 PM   #2 (permalink)
Forum Expert
 
Join Date: Dec 2005
Location: Germany
Age: 31
Posts: 401
Default

I don't know, that code works flawlessly on my SVN 181 server on WinXP. Maybe a Mono thing?

BTW, kudos for posting something I pm'ed you about... oh, half a year ago?
Setharnas is offline   Reply With Quote
Old 12-04-2007, 09:32 AM   #3 (permalink)
Forum Expert
 
Cheetah2003's Avatar
 
Join Date: Jun 2006
Location: Laramie, Wyoming
Age: 36
Posts: 354
Send a message via ICQ to Cheetah2003 Send a message via AIM to Cheetah2003 Send a message via MSN to Cheetah2003 Send a message via Yahoo to Cheetah2003
Default

Quote:
Originally Posted by Setharnas View Post
I don't know, that code works flawlessly on my SVN 181 server on WinXP. Maybe a Mono thing?

BTW, kudos for posting something I pm'ed you about... oh, half a year ago?
I was out of it for quite a while. What did I post about? Hehe.
__________________
Take a walk on The Wild side.
Cheetah2003 is offline   Reply With Quote
Old 12-04-2007, 09:47 AM   #4 (permalink)
Forum Expert
 
Join Date: Dec 2005
Location: Germany
Age: 31
Posts: 401
Default

Yeah, I realized that when your 'last activity' date didn't change anymore.

It was nothing specific, just some error logs you posted with that timestamp already included. I just sent you a pm asking what to do in order to get that, too. Very useful thing IMO, should be distro default.

It wasn't meant as ironic when I wrote that line, I'm glad to finally have an answer.
Setharnas is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5