Esempio n. 1
0
        public void Add(string message)
        {
            string msg = $"{DateTime.Now}: {message}\n";

            Console.Write(msg);
            EventLogged?.Invoke(msg);
        }
        /// <inheritdoc />
        public void Write(Exception ex, Dictionary <string, string> data, [CallerFilePath] string callerPath = null, [CallerMemberName] string callerMemberName = null, [CallerLineNumber] int callerLineNumber = 0)
        {
            var applicationEvent = new ExceptionEvent(
                ex,
                data,
                callerPath,
                callerMemberName,
                callerLineNumber);

            this.writer.Write(applicationEvent);
            EventLogged?.Invoke(this, new EventLoggedEventArgs(applicationEvent));
        }
        /// <inheritdoc />
        public void Write(string name, double metric, [CallerFilePath] string callerPath = null, [CallerMemberName] string callerMemberName = null, [CallerLineNumber] int callerLineNumber = 0)
        {
            var applicationEvent = new MetricEvent(
                name,
                metric,
                null,
                callerPath,
                callerMemberName,
                callerLineNumber);

            this.writer.Write(applicationEvent);
            EventLogged?.Invoke(this, new EventLoggedEventArgs(applicationEvent));
        }
Esempio n. 4
0
 private static void WriteLine(string msg, LogType logType, [CallerMemberName] string memberName = "",
                               [CallerFilePath] string sourceFilePath = "", bool invokeEvent = true)
 {
     if (_logWriter == null)
     {
         LogQueue.Enqueue(new Tuple <string, LogType, string, string>(msg, logType, memberName, sourceFilePath));
     }
     else
     {
         _logWriter.WriteLine(msg, logType, memberName, sourceFilePath);
     }
     if (invokeEvent)
     {
         EventLogged?.Invoke(new ErrorEventArgs(logType, msg, sourceFilePath, memberName));
     }
 }
Esempio n. 5
0
 public static void Fatal(Exception ex, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "")
 {
     WriteLine(ex.ToString(), LogType.Fatal, memberName, sourceFilePath, false);
     EventLogged?.Invoke(new ErrorEventArgs(LogType.Fatal, ex, sourceFilePath, memberName));
 }