Cleanup log system

This commit is contained in:
Marc Hernandez 2025-08-18 20:06:59 -07:00
parent 4563db15a6
commit bba0e96007

View File

@ -553,6 +553,7 @@ static public class log
var timeLine = new LogEvent( LogType.Raw, $"D A T E {time.Year}/{time.Month.ToString( "00" )}/{time.Day.ToString( "00" )} T I M E {time.Hour.ToString( "00" )}:{time.Minute.ToString( "00" )}:{time.Second.ToString( "00" )}.{time.Millisecond.ToString( "000" )}{time.Microsecond.ToString( "000" )}", "", 0, "", "lib.time", "", null );
//writeToAll( endLine );
writeToAll( blankLine );
writeToAll( blankLine );
@ -569,6 +570,10 @@ static public class log
LogEvent msgFilename = new LogEvent( LogType.Info, $"Logging in {filename}", "", 0, "", "log.startup", "", null );
writeToAll( msgFilename );
var optionsLine = new LogEvent( LogType.Info, $"Endpoints: {endpoints}", "", 0, "", "log.startup", "", null );
writeToAll( optionsLine );
StartThread();
@ -636,13 +641,19 @@ static public class log
static void threadLoop()
{
Console.WriteLine( $"**********************************************************\n" );
Console.WriteLine( $"Thread started" );
log.info( $"Thread started" );
while( s_threading != ThreadState.Running )
{
// TODO PERF Replace this with a semaphore/mutex
Thread.Sleep( 1 );
}
while( s_threading != ThreadState.Running )
while( s_threading == ThreadState.Running )
{
while( s_events.TryDequeue( out var evt ) )
{
@ -910,6 +921,8 @@ static public class log
var finalEndpoints = s_logEPforCat.TryGetValue( evt.Cat, out var ep ) ? ep & s_endpoints : s_endpoints;
//Console.WriteLine( $"Final endpoints for {evt.Cat} = {finalEndpoints}" );
if( ( finalEndpoints & Endpoints.File ) == Endpoints.File )
{
var line = msgFile( evt );