public virtual void Write(LogSeverity level, string payload, LoggingMeta meta) { if (!IsLevelEnabled(level)) { return; } int currentMetaHash = parent.Meta.MetaHash ^ this.Meta.MetaHash; if (!mergedMetaHash.HasValue || currentMetaHash != mergedMetaHash.Value) { mergedMeta = parent.Meta.Merge(this.Meta); mergedMetaHash = currentMetaHash; } LoggingMeta localMergedMeta = mergedMeta; if (meta.Count > 0) { localMergedMeta = localMergedMeta.Merge(meta); } for (int i = 0; i < parent.Handlers.Count; i++) { parent.Handlers[i].Write(level, payload, localMergedMeta, this); } for (int i = 0; i < handlers.Count; i++) { handlers[i].Write(level, payload, localMergedMeta, this); } }
internal Logger(string name, LogManager parent) { this.Name = name; this.parent = parent; this.Severity = LogSeverity.TRACE; this.Meta = new LoggingMeta(); this.handlers = new List <ILoggingHandler>(); }
public void Write(LogSeverity level, string payload, LoggingMeta meta, params object[] format) { if (format != null && format.Length > 0) { Write(level, string.Format(payload, format), meta); } else { Write(level, payload, meta); } }
public LoggingMeta Merge(params LoggingMeta[] meta) { LoggingMeta newMeta = new LoggingMeta(this.meta); foreach (var m in meta) { foreach (var pair in m) { newMeta[pair.Key] = pair.Value; } } return(newMeta); }
public void Warn(string payload, LoggingMeta meta, params object[] format) { Write(LogSeverity.WARNING, payload, meta, format); }
public void Info(string payload, LoggingMeta meta, params object[] format) { Write(LogSeverity.INFO, payload, meta, format); }
public void Debug(string payload, LoggingMeta meta, params object[] format) { Write(LogSeverity.DEBUG, payload, meta, format); }
public void Trace(string payload, LoggingMeta meta, params object[] format) { Write(LogSeverity.TRACE, payload, meta, format); }
public void Critical(string payload, LoggingMeta meta, params object[] format) { Write(LogSeverity.CRITICAL, payload, meta, format); }
public void Error(string payload, LoggingMeta meta, params object[] format) { Write(LogSeverity.ERROR, payload, meta, format); }
public LogManager() { this.Severity = LogSeverity.TRACE; this.Meta = new LoggingMeta(); this.handlers = new List <ILoggingHandler>(); }
public LogManager(LogSeverity severity, LoggingMeta meta) : this(severity) { this.Meta = this.Meta.Merge(meta); }
public LogManager(LogSeverity severity, LoggingMeta meta, params ILoggingHandler[] handlers) : this(severity, meta) { this.handlers.AddRange(handlers); }