Cleanup DisposableTimer log messages

This commit is contained in:
Stephan
2018-09-20 08:49:19 +02:00
parent bd613ec971
commit 16eab3eb49

View File

@@ -30,17 +30,17 @@ namespace Umbraco.Core.Logging
_endMessage = endMessage;
_failMessage = failMessage;
_thresholdMilliseconds = thresholdMilliseconds < 0 ? 0 : thresholdMilliseconds;
_timingId = Guid.NewGuid().ToString("N");
_timingId = Guid.NewGuid().ToString("N").Substring(0, 7); // keep it short-ish
if (thresholdMilliseconds == 0)
{
switch (_level)
{
case LogLevel.Debug:
logger.Debug(loggerType, "[Timing {TimingId}] {StartMessage}", _timingId, startMessage);
logger.Debug(loggerType, "{StartMessage} [Timing {TimingId}]", _timingId, startMessage);
break;
case LogLevel.Information:
logger.Info(loggerType, "[Timing {TimingId}] {StartMessage}", _timingId, startMessage);
logger.Info(loggerType, "{StartMessage} [Timing {TimingId}]", _timingId, startMessage);
break;
default:
throw new ArgumentOutOfRangeException(nameof(level));
@@ -84,15 +84,15 @@ namespace Umbraco.Core.Logging
{
if (_failed)
{
_logger.Error(_loggerType, _failException, "[Timing {TimingId}] {FailMessage} ({Duration}ms)", _timingId, _failMessage, Stopwatch.ElapsedMilliseconds);
_logger.Error(_loggerType, _failException, "{FailMessage} ({Duration}ms) [Timing {TimingId}]", _timingId, _failMessage, Stopwatch.ElapsedMilliseconds);
}
else switch (_level)
{
case LogLevel.Debug:
_logger.Debug(_loggerType, "[Timing {TimingId}] {EndMessage} ({Duration}ms)", _timingId, _endMessage, Stopwatch.ElapsedMilliseconds);
_logger.Debug(_loggerType, "{EndMessage} ({Duration}ms) [Timing {TimingId}]", _timingId, _endMessage, Stopwatch.ElapsedMilliseconds);
break;
case LogLevel.Information:
_logger.Info(_loggerType, "[Timing {TimingId}] {EndMessage} ({Duration}ms)", _timingId, _endMessage, Stopwatch.ElapsedMilliseconds);
_logger.Info(_loggerType, "{EndMessage} ({Duration}ms) [Timing {TimingId}]", _timingId, _endMessage, Stopwatch.ElapsedMilliseconds);
break;
// filtered in the ctor
//default: