Exemple #1
0
        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);
            }
        }
Exemple #2
0
 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>();
 }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
        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);
        }
Exemple #5
0
 public void Warn(string payload, LoggingMeta meta, params object[] format)
 {
     Write(LogSeverity.WARNING, payload, meta, format);
 }
Exemple #6
0
 public void Info(string payload, LoggingMeta meta, params object[] format)
 {
     Write(LogSeverity.INFO, payload, meta, format);
 }
Exemple #7
0
 public void Debug(string payload, LoggingMeta meta, params object[] format)
 {
     Write(LogSeverity.DEBUG, payload, meta, format);
 }
Exemple #8
0
 public void Trace(string payload, LoggingMeta meta, params object[] format)
 {
     Write(LogSeverity.TRACE, payload, meta, format);
 }
Exemple #9
0
 public void Critical(string payload, LoggingMeta meta, params object[] format)
 {
     Write(LogSeverity.CRITICAL, payload, meta, format);
 }
Exemple #10
0
 public void Error(string payload, LoggingMeta meta, params object[] format)
 {
     Write(LogSeverity.ERROR, payload, meta, format);
 }
Exemple #11
0
 public LogManager()
 {
     this.Severity = LogSeverity.TRACE;
     this.Meta     = new LoggingMeta();
     this.handlers = new List <ILoggingHandler>();
 }
Exemple #12
0
 public LogManager(LogSeverity severity, LoggingMeta meta) : this(severity)
 {
     this.Meta = this.Meta.Merge(meta);
 }
Exemple #13
0
 public LogManager(LogSeverity severity, LoggingMeta meta, params ILoggingHandler[] handlers) : this(severity, meta)
 {
     this.handlers.AddRange(handlers);
 }