x) split out formatting text portion of log messages

This commit is contained in:
Marc Hernandez 2024-02-20 14:44:39 -08:00
parent 3bbf5e50df
commit 94ce81da96

View File

@ -68,15 +68,15 @@ static public class log
cat = autoCat;
}
else
{
var pathPieces = path.Split( '\\' );
if(pathPieces.Length < 2)
{
pathPieces = path.Split('/');
}
{
var pathPieces = path.Split( '\\' );
if(pathPieces.Length < 2)
{
pathPieces = path.Split('/');
}
var lastDir = pathPieces[ pathPieces.Length - 2 ];
ImmutableInterlocked.AddOrUpdate( ref s_shortname, pathHash, lastDir, ( key, value ) => { return lastDir; } );
@ -378,6 +378,25 @@ static public class log
}
}
static public string msgHeader( LogEvent evt )
{
char sym = getSymbol( evt.LogType );
var truncatedCat = evt.Cat.Substring( 0, Math.Min( 8, evt.Cat.Length ) );
var msgHdr = string.Format( "{0,-8}{1}| ", truncatedCat, sym );
return msgHdr;
}
static public string msgFrom( LogEvent evt )
{
var msgHdr = msgHeader( evt );
string finalLine = $"{msgHdr}{evt.Msg}";
return finalLine;
}
static private void writeToAll( LogEvent evt )
{
@ -386,12 +405,8 @@ static public class log
// _SHOULDNT_ need this since we lock at the top.
//lock( this )
{
char sym = getSymbol( evt.LogType );
var truncatedCat = evt.Cat.Substring( 0, Math.Min( 8, evt.Cat.Length ) );
string finalLine = string.Format( "{0,-8}{1}| {2}", truncatedCat, sym, evt.Msg );
var finalLine = msgFrom( evt );
//Console.WriteLine( finalMsg );
//Console.Out.Write( finalMsg );