/// <summary> /// Returns the logger for the existing name. /// </summary> /// <param name="name">The case sensitive logger name.</param> /// <param name="writer">Optionally specifies the output writer. This defaults to <see cref="Console.Error"/>.</param> /// <returns>The <see cref="INeonLogger"/> instance.</returns> private INeonLogger InternalGetLogger(string name, TextWriter writer = null) { name = name ?? string.Empty; lock (nameToLogger) { if (!nameToLogger.TryGetValue(name, out var logger)) { logger = new NeonLogger(this, name, writer: writer); nameToLogger.Add(name, logger); } return(logger); } }
/// <inheritdoc/> public void LogMetrics(LogLevel level, IEnumerable <string> txtFields, IEnumerable <double> numFields) { var txtCount = 0; var numCount = 0; if (txtFields != null) { txtCount = txtFields.Count(); } if (numFields != null) { numCount = numFields.Count(); } if (txtCount == 0 && numCount == 0) { return; // Nothing to write. } var message = NeonLogger.FormatMetrics(txtFields, numFields); switch (level) { case LogLevel.Critical: LogCritical(message); break; case LogLevel.Debug: LogDebug(message); break; case LogLevel.Error: LogError(message); break; case LogLevel.Info: LogInfo(message); break; case LogLevel.None: break; // NOP case LogLevel.SError: LogSError(message); break; case LogLevel.SInfo: LogSInfo(message); break; case LogLevel.Warn: LogWarn(message); break; default: throw new NotImplementedException(); } }
/// <inheritdoc/> public void LogMetrics(LogLevel level, IEnumerable <string> txtFields, IEnumerable <double> numFields) { log.LogMetrics(level, txtFields, numFields); capture.AppendLine($"[{level.ToString().ToUpperInvariant()}] {NeonLogger.FormatMetrics(txtFields, numFields)}"); }