Logging polish

This commit is contained in:
Marc Hernandez 2019-12-07 23:40:20 -08:00
parent 24cbb17615
commit afd97b1522

14
Log.cs
View File

@ -84,7 +84,7 @@ namespace lib
{ {
var pathPieces = path.Split('\\'); var pathPieces = path.Split('\\');
var lastDir = pathPieces[pathPieces.Length - 1]; var lastDir = pathPieces[pathPieces.Length - 2];
ImmutableInterlocked.AddOrUpdate( ref m_shortname, path, lastDir, ( key, value ) => { return lastDir; } ); ImmutableInterlocked.AddOrUpdate( ref m_shortname, path, lastDir, ( key, value ) => { return lastDir; } );
@ -313,7 +313,7 @@ namespace lib
} }
*/ */
private char getSymbol( LogType type ) public static char getSymbol( LogType type )
{ {
switch( type ) switch( type )
{ {
@ -322,7 +322,7 @@ namespace lib
case LogType.Debug: case LogType.Debug:
return ' '; return ' ';
case LogType.Info: case LogType.Info:
return ':'; return ' ';
case LogType.High: case LogType.High:
return '+'; return '+';
case LogType.Warn: case LogType.Warn:
@ -345,7 +345,9 @@ namespace lib
{ {
char sym = getSymbol( evt.LogType ); char sym = getSymbol( evt.LogType );
string finalMsg = string.Format( "{0,-6}{1}| {2}", evt.Cat, sym, evt.Msg ); var truncatedCat = evt.Cat.Substring(0, Math.Min( 8, evt.Cat.Length ) );
string finalLine = string.Format( "{0,-8}{1}| {2}", truncatedCat, sym, evt.Msg );
//Console.WriteLine( finalMsg ); //Console.WriteLine( finalMsg );
//Console.Out.Write( finalMsg ); //Console.Out.Write( finalMsg );
@ -361,7 +363,7 @@ namespace lib
} }
*/ */
m_writer.WriteLine( finalMsg ); m_writer.WriteLine( finalLine );
m_writer.Flush(); m_writer.Flush();
@ -374,7 +376,7 @@ namespace lib
} }
} }
} }
catch( Exception ) catch( Exception ex )
{ {
//oops. //oops.
//int dummy = 0; //int dummy = 0;