Update logging functionality: Refactored log stop method, added missing end line write, and improved time formatting. Made adjustments to AngleSingle class for nullability.

This commit is contained in:
Marc Hernandez 2024-05-26 16:49:29 -07:00
parent f672ab9d2f
commit 05656d469a
3 changed files with 22 additions and 11 deletions

View File

@ -11,10 +11,14 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>preview</LangVersion>
<!--
I Want to turn this on, but cant yet. Implementing nullability 1 file at a gime
<Nullable>enable</Nullable>
-->
</PropertyGroup>
<PropertyGroup>
<NoWarn>$(NoWarn);SYSLIB0050</NoWarn>
<NoWarn>$(NoWarn);SYSLIB0050;CS8981</NoWarn>
</PropertyGroup>
<ItemGroup>

View File

@ -368,8 +368,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( endLine );
writeToAll( blankLine );
writeToAll( blankLine );
writeToAll( beginLine );
@ -378,7 +377,6 @@ static public class log
writeToAll( blankLine );
while( s_running )
{
while( s_events.TryDequeue( out var evt ) )
@ -389,12 +387,22 @@ static public class log
// TODO PERF Replace this with a semaphore/mutex
Thread.Sleep( 0 );
}
writeToAll( endLine );
}
static void stop()
public static void stop()
{
if( !s_running ) return;
s_running = false;
while( s_thread.IsAlive )
{
Thread.Sleep( 0 );
}
s_writer.Close();
s_stream.Close();
@ -500,7 +508,7 @@ static public class log
var truncatedCat = evt.Cat.Substring( 0, Math.Min( s_catWidth, evt.Cat.Length ) );
var timeHdr = $"{evt.Time.Year}-{evt.Time.Month.ToString("00")}-{evt.Time.Day.ToString("00")} {evt.Time.Hour.ToString("00")}:{evt.Time.Minute.ToString("00")}:{evt.Time.Second.ToString("00")}.{evt.Time.Millisecond.ToString("000")}";
var timeHdr = $"{evt.Time.Year}-{evt.Time.Month.ToString("00")}-{evt.Time.Day.ToString("00")} {evt.Time.Hour.ToString("00")}:{evt.Time.Minute.ToString("00")}:{evt.Time.Second.ToString("00")}.{evt.Time.Millisecond.ToString("000")}{evt.Time.Microsecond.ToString("000")}";
var msgHdr = string.Format( $"{timeHdr} | {{0,-{s_catWidth}}}{{1}}| ", truncatedCat, sym );
@ -514,7 +522,6 @@ static public class log
}
static public string msgPrint( LogEvent evt )
{
var msgHdr = headerPrint( evt );

View File

@ -771,7 +771,7 @@ namespace math
/// its value is equal to the value of the current math.Angle
/// object; otherwise, false.
/// </returns>
public override bool Equals( object obj )
public override bool Equals( object? obj )
{
return ( obj is AngleSingle ) && ( this == (AngleSingle)obj );
}