Log fixes
This commit is contained in:
parent
6f13bd834a
commit
380974d673
@ -294,12 +294,16 @@ static public class log
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Endpoints s_endpoints = Endpoints.Console;
|
static Endpoints s_endpoints = Endpoints.Console;
|
||||||
|
static int s_catWidth = 14;
|
||||||
|
|
||||||
static void startup( string filename, Endpoints endpoints )
|
static void startup( string filename, Endpoints endpoints )
|
||||||
{
|
{
|
||||||
|
s_endpoints = endpoints;
|
||||||
|
|
||||||
var start = new ThreadStart( run );
|
var start = new ThreadStart( run );
|
||||||
|
|
||||||
s_thread = new Thread( start );
|
s_thread = new Thread( start );
|
||||||
|
s_thread.Name = $"Logging";
|
||||||
s_thread.Start();
|
s_thread.Start();
|
||||||
|
|
||||||
//TODO: Fix this so itll work without a directory.
|
//TODO: Fix this so itll work without a directory.
|
||||||
@ -312,12 +316,16 @@ static public class log
|
|||||||
Directory.CreateDirectory( dir );
|
Directory.CreateDirectory( dir );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s_stream = new FileStream( filename, FileMode.Append, FileAccess.Write );
|
s_stream = new FileStream( filename, FileMode.Append, FileAccess.Write );
|
||||||
s_writer = new StreamWriter( s_stream );
|
s_writer = new StreamWriter( s_stream );
|
||||||
|
|
||||||
s_errorStream = new FileStream( filename + ".error", FileMode.Append, FileAccess.Write );
|
s_errorStream = new FileStream( filename + ".error", FileMode.Append, FileAccess.Write );
|
||||||
s_errorWriter = new StreamWriter( s_errorStream );
|
s_errorWriter = new StreamWriter( s_errorStream );
|
||||||
|
|
||||||
|
|
||||||
|
info( $"Logging in {filename}" );
|
||||||
|
|
||||||
//Debug.Listeners.Add( this );
|
//Debug.Listeners.Add( this );
|
||||||
|
|
||||||
//var evt = CreateLogEvent( LogType.Info, $"startup", "System", null );
|
//var evt = CreateLogEvent( LogType.Info, $"startup", "System", null );
|
||||||
@ -427,9 +435,9 @@ static public class log
|
|||||||
{
|
{
|
||||||
char sym = getSymbol( evt.LogType );
|
char sym = getSymbol( evt.LogType );
|
||||||
|
|
||||||
var truncatedCat = evt.Cat.Substring( 0, Math.Min( 8, evt.Cat.Length ) );
|
var truncatedCat = evt.Cat.Substring( 0, Math.Min( s_catWidth, evt.Cat.Length ) );
|
||||||
|
|
||||||
var msgHdr = string.Format( "{0,-8}{1}| ", truncatedCat, sym );
|
var msgHdr = string.Format( $"{{0,-{s_catWidth}}}{{1}}| ", truncatedCat, sym );
|
||||||
|
|
||||||
return msgHdr;
|
return msgHdr;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user