コード例 #1
0
        public override void Log(Logger.MessageType severity_, string message_)
        {
            if (severity_ < Logger.MessageType.Debug)
            {
                return;
            }
            FileStream   fileStream   = (FileStream)null;
            StreamWriter streamWriter = (StreamWriter)null;
            string       message_1    = DateTime.Now.ToString() + ": " + message_;

            lock (FileLog.b)
            {
                while (fileStream == null)
                {
                    try
                    {
                        fileStream = new FileStream(this.d + this.a, FileMode.OpenOrCreate, FileAccess.Write);
                    }
                    catch (IOException exception_0)
                    {
                        fileStream = (FileStream)null;
                        Thread.Sleep(0);
                    }
                }
                try
                {
                    streamWriter = new StreamWriter((Stream)fileStream);
                    streamWriter.BaseStream.Seek(0L, SeekOrigin.End);
                    streamWriter.WriteLine(message_1);
                    streamWriter.Flush();
                }
                finally
                {
                    if (streamWriter != null)
                    {
                        streamWriter.Close();
                    }
                }
            }
            if (this.c == null)
            {
                return;
            }
            this.c(message_1);
        }
コード例 #2
0
 /// <summary>
 /// Set the log level of the Logger. All log records with a MessageType
 /// smaller or equal the log level will be logged. Logging to the Windows
 /// Event Log is not affected by the log level.
 /// </summary>
 /// <param name="level">One of the possible logging levels:
 /// <code>FAIL | ERROR | WARN | INFO | DEBUG</code></param>
 public static void SetLogLevel(String level)
 {
     if (level.ToUpper().Equals("INFO"))
     {
         globalLogLevel = MessageType.INFO;
     }
     else if (level.ToUpper().Equals("WARN"))
     {
         globalLogLevel = MessageType.WARN;
     }
     else if (level.ToUpper().Equals("ERROR"))
     {
         globalLogLevel = MessageType.ERROR;
     }
     else if (level.ToUpper().Equals("FAIL"))
     {
         globalLogLevel = MessageType.FAIL;
     }
     else
     {
         globalLogLevel = MessageType.DEBUG;
     }
 }
コード例 #3
0
 bool canShowMessage(Logger.MessageType type_)
 {
     return((showLogs && (type_ == Logger.MessageType.Log)) ||
            (showWarnings && (type_ == Logger.MessageType.Warning)) ||
            (showErrors && (type_ == Logger.MessageType.Error)));
 }
コード例 #4
0
ファイル: Logger.cs プロジェクト: lieblingek/CSharp
 public abstract void Log(Logger.MessageType Severity, string Message);
コード例 #5
0
ファイル: Logger.cs プロジェクト: lieblingek/CSharp
 public abstract void Log(Logger.MessageType Severity, Exception Message);
コード例 #6
0
ファイル: Builder.cs プロジェクト: MKHenson/Luminate
 /// <summary>
 /// Makes a thread safe log message
 /// </summary>
 /// <param name="message"></param>
 private static void Log(string message, Logger.MessageType type)
 {
     Logger.Singleton.Log(message, type);
 }
コード例 #7
0
 public override void Log(Logger.MessageType severity_, Exception message_)
 {
     this.Log(severity_, message_.Message);
 }
コード例 #8
0
 private Logger()
 {
     globalLogLevel = MessageType.DEBUG;
 }
コード例 #9
0
 public LoggerOutputEventArgs(Logger.MessageType mtype, string msg)
 {
     MessageType = mtype;
     MessageText = msg;
 }