Skip to content

Commit

Permalink
Allow LogLevel template to display milliseconds (#6126)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelhamed committed Sep 29, 2022
1 parent a04daec commit 8daa482
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/core/Akka/Event/LogEvent.cs
Expand Up @@ -7,7 +7,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Akka.Actor;

Expand Down Expand Up @@ -89,16 +88,14 @@ protected LogEvent()
public abstract LogLevel LogLevel();

/// <summary>
/// Returns a <see cref="System.String" /> that represents this LogEvent.
/// Returns a <see cref="string" /> that represents this LogEvent.
/// </summary>
/// <returns>A <see cref="System.String" /> that represents this LogEvent.</returns>
/// <returns>A <see cref="string" /> that represents this LogEvent.</returns>
public override string ToString()
{
if(Cause == null)
return
$"[{LogLevel().PrettyNameFor()}][{Timestamp}][Thread {Thread.ManagedThreadId.ToString().PadLeft(4, '0')}][{LogSource}] {Message}";
return
$"[{LogLevel().PrettyNameFor()}][{Timestamp}][Thread {Thread.ManagedThreadId.ToString().PadLeft(4, '0')}][{LogSource}] {Message}{Environment.NewLine}Cause: {Cause}";
return Cause == null
? $"[{LogLevel().PrettyNameFor()}][{Timestamp:MM/dd/yyyy hh:mm:ss.fff}][Thread {Thread.ManagedThreadId.ToString().PadLeft(4, '0')}][{LogSource}] {Message}"
: $"[{LogLevel().PrettyNameFor()}][{Timestamp:MM/dd/yyyy hh:mm:ss.fff}][Thread {Thread.ManagedThreadId.ToString().PadLeft(4, '0')}][{LogSource}] {Message}{Environment.NewLine}Cause: {Cause}";
}
}
}

0 comments on commit 8daa482

Please sign in to comment.