示例#1
0
        public static void Log(string message, Helpers.LogLevel Level, GridClient client, Exception exception)
        {
            if (Settings.LOG_LEVEL >= Level)
            {
                StringBuilder NewMessage = new StringBuilder();
                if (client != null)
                {
                    if (client.Settings.LOG_NAMES)
                    {
                        NewMessage.Append("{");
                        NewMessage.Append(client.Self.Name);
                        NewMessage.Append("} ");
                    }
                }
                NewMessage.Append(message);
                switch (Settings.LOG_WRITER)
                {
                case "NoLogWriter":
                {
                    break;
                }

                default:
                {
                    ConsoleWriter.LogMessage(NewMessage, Level);
                    break;
                }
                }
            }
        }
 static void Client_OnLogMessage(object message, Helpers.LogLevel level)
 {
     if (level >= Helpers.LogLevel.Warning)
     {
         Console.WriteLine(level + ": " + message);
     }
 }
示例#3
0
 /// <summary>
 /// Send a log message to the debugging output system
 /// </summary>
 /// <param name="message">The log message</param>
 /// <param name="level">From the LogLevel enum, either Info, Warning, or Error</param>
 public void Log(string message, Helpers.LogLevel level)
 {
     if (Debug)
     {
         Console.WriteLine(level.ToString() + ": " + message);
     }
 }
示例#4
0
 static void client_OnLogMessage(string message, Helpers.LogLevel level)
 {
     if (level == Helpers.LogLevel.Warning || level == Helpers.LogLevel.Error)
     {
         Console.WriteLine(level.ToString() + ": " + message);
     }
 }
示例#5
0
 /// <summary>
 /// Send a log message to the debugging output system
 /// </summary>
 /// <param name="message">The log message</param>
 /// <param name="level">From the LogLevel enum, either Info, Warning, or Error</param>
 public void Log(string message, Helpers.LogLevel level)
 {
     if (OnLogMessage != null)
     {
         OnLogMessage(message, level);
     }
     else
     {
         Console.WriteLine(level.ToString().ToUpper() + ": " + message);
     }
 }
示例#6
0
文件: Logger.cs 项目: hibecki/workb
        /// <summary>
        /// Send a log message to the logging engine
        /// </summary>
        /// <param name="message">The log message</param>
        /// <param name="level">The severity of the log entry</param>
        /// <param name="client">Instance of the client</param>
        /// <param name="exception">Exception that was raised</param>
        public static void Log(object message, Helpers.LogLevel level, GridClient client, Exception exception)
        {
            if (client != null && client.Settings.LOG_NAMES)
            {
                message = String.Format("<{0}>: {1}", client.Self.Name, message);
            }

            if (OnLogMessage != null)
            {
                OnLogMessage(message, level);
            }

            switch (level)
            {
            case Helpers.LogLevel.Debug:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug)
                {
                    LogInstance.Debug(message, exception);
                }
                break;

            case Helpers.LogLevel.Info:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Info)
                {
                    LogInstance.Info(message, exception);
                }
                break;

            case Helpers.LogLevel.Warning:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Info ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Warning)
                {
                    LogInstance.Warn(message, exception);
                }
                break;

            case Helpers.LogLevel.Error:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Info ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Warning ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Error)
                {
                    LogInstance.Error(message, exception);
                }
                break;

            default:
                break;
            }
        }
示例#7
0
        public static void LogMessage(StringBuilder messageBuilder, Helpers.LogLevel Level)
        {
            var    date    = DateTime.Now;
            string Message = messageBuilder.ToString();

            messageBuilder.Clear();
            messageBuilder.Append("[");
            if (date.Hour < 10)
            {
                messageBuilder.Append("0");
            }
            messageBuilder.Append(date.Hour.ToString());
            messageBuilder.Append(":");
            if (date.Minute < 10)
            {
                messageBuilder.Append("0");
            }
            messageBuilder.Append(date.Minute.ToString());
            messageBuilder.Append("] ");
            switch (Level)
            {
            case Helpers.LogLevel.Debug:
            {
                messageBuilder.Append("Debug - ");
                break;
            }

            case Helpers.LogLevel.Info:
            {
                messageBuilder.Append("Status - ");
                break;
            }

            case Helpers.LogLevel.Warning:
            {
                messageBuilder.Append("Warn - ");
                break;
            }

            case Helpers.LogLevel.Error:
            {
                messageBuilder.Append("Error - ");
                break;
            }

            default:
                break;
            }
            messageBuilder.Append(Message);
            WriteMessage(Message);
        }
示例#8
0
        /// <summary>
        /// Send a log message to the logging engine
        /// </summary>
        /// <param name="message">The log message</param>
        /// <param name="level">The severity of the log entry</param>
        /// <param name="client">Instance of the client</param>
        /// <param name="exception">Exception that was raised</param>
        public static void Log(object message, Helpers.LogLevel level, GridClient client, Exception exception)
        {
            if (client != null && client.Settings.LOG_NAMES)
            {
                message = $"<{client.Self.Name}>: {message}";
            }

            OnLogMessage?.Invoke(message, level);

            switch (level)
            {
            case Helpers.LogLevel.Debug:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug)
                {
                    LogInstance.Debug(message, exception);
                }
                break;

            case Helpers.LogLevel.Info:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Info)
                {
                    LogInstance.Info(message, exception);
                }
                break;

            case Helpers.LogLevel.Warning:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Info ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Warning)
                {
                    LogInstance.Warn(message, exception);
                }
                break;

            case Helpers.LogLevel.Error:
                if (Settings.LOG_LEVEL == Helpers.LogLevel.Debug ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Info ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Warning ||
                    Settings.LOG_LEVEL == Helpers.LogLevel.Error)
                {
                    LogInstance.Error(message, exception);
                }
                break;

            default:
                break;
            }
        }
示例#9
0
 //comes in on separate thread
 private void client_OnLogMessage(object message, Helpers.LogLevel level)
 {
     try
     {
         if (this.IsHandleCreated)
         {
             BeginInvoke(new Logger.LogCallback(ReceivedLogMessage), new object[] { message, level });
         }
         else
         {
             initQueue.Add(new DebugLogMessage((string)message, level, DateTime.Now));
         }
     }
     catch {; }
 }
示例#10
0
        private void ReceivedLogMessage(object message, Helpers.LogLevel level, DateTime dte)
        {
            try
            {
                RichTextBox rtb = null;

                switch (level)
                {
                case Helpers.LogLevel.Info:
                    rtb = rtbInfo;
                    break;

                case Helpers.LogLevel.Warning:
                    rtb = rtbWarning;
                    break;

                case Helpers.LogLevel.Error:
                    rtb = rtbError;
                    break;

                case Helpers.LogLevel.Debug:
                    rtb = rtbDebug;
                    break;
                }

                string msg = (string)message;
                if (msg.Contains("ParticipantUpdatedEvent"))
                {
                    return;
                }

                rtb.AppendText("[" + dte.ToString() + "] " + msg + "\n");
            }
            catch (Exception ex)
            {
                Logger.Log("Logger error on receiving Log message: " + ex.Message, Helpers.LogLevel.Error);
            }
        }
示例#11
0
        /// <summary>
        /// Send a log message to the debugging output system
        /// </summary>
        /// <param name="message">The log message</param>
        /// <param name="level">The severity of the log entry</param>
        public void Log(string message, Helpers.LogLevel level)
        {
            if (level == Helpers.LogLevel.Debug && !Settings.DEBUG)
            {
                return;
            }

            if (OnLogMessage != null)
            {
                try { OnLogMessage(message, level); }
                catch (Exception e) { Console.WriteLine(e.ToString()); }
            }
            else
            {
                if (Settings.LOG_NAMES)
                {
                    Console.WriteLine("{0} [{1} {2}]: {3}", level.ToString().ToUpper(), Self.FirstName, Self.LastName, message);
                }
                else
                {
                    Console.WriteLine("{0}: {1}", level.ToString().ToUpper(), message);
                }
            }
        }
示例#12
0
 /// <summary>
 /// Send a log message to the logging engine
 /// </summary>
 /// <param name="message">The log message</param>
 /// <param name="level">The severity of the log entry</param>
 /// <param name="exception">Exception that was raised</param>
 public static void Log(object message, Helpers.LogLevel level, Exception exception)
 {
     Log(message, level, null, exception);
 }
示例#13
0
 void client_OnLogMessage(string message, Helpers.LogLevel level)
 {
     Log("libsl: " + level.ToString() + ": " + message);
 }
示例#14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 /// <param name="level"></param>
 public static void LogStatic(string message, Helpers.LogLevel level)
 {
     Console.WriteLine("{0}: {1}", level.ToString().ToUpper(), message);
 }
示例#15
0
 public static void Log(string message, Helpers.LogLevel Level, Exception exception)
 {
     Log(message, Level, null, exception);
 }
示例#16
0
 public static void Log(string message, Helpers.LogLevel Level, GridClient client)
 {
     Log(message, Level, null, null);
 }
示例#17
0
 public static void Log(string message, Helpers.LogLevel Level)
 {
     Log(message, Level, null, null);
 }
示例#18
0
 public static void LogFormat(string Message, Helpers.LogLevel Level, string[] Values)
 {
     Log(String.Format(Message, Values), Level);
 }
示例#19
0
 /// <summary>
 /// Send a log message to the logging engine
 /// </summary>
 /// <param name="message">The log message</param>
 /// <param name="level">The severity of the log entry</param>
 public static void Log(object message, Helpers.LogLevel level)
 {
     Log(message, level, null, null);
 }
示例#20
0
 void client_OnLogMessage(string message, Helpers.LogLevel level)
 {
     Log("libsl: " + level.ToString() + ": " + message + Environment.NewLine);
 }
示例#21
0
 public DebugLogMessage(string message, Helpers.LogLevel level)
 {
     this.message = message;
     this.level = level;
 }
示例#22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 /// <param name="level"></param>
 /// <param name="exception"></param>
 public static void LogStatic(string message, Helpers.LogLevel level, Exception exception)
 {
     Console.WriteLine("{0} [libsecondlife]: {1} ({2})", level.ToString().ToUpper(), message, exception);
 }
示例#23
0
 public DebugLogMessage(string message, Helpers.LogLevel level, DateTime tstamp)
 {
     this.message = message;
     this.level = level;
     this.timestamp = tstamp;
 }
示例#24
0
 /// <summary>
 /// Send a log message to the logging engine
 /// </summary>
 /// <param name="message">The log message</param>
 /// <param name="level">The severity of the log entry</param>
 /// <param name="client">Instance of the client</param>
 public static void Log(object message, Helpers.LogLevel level, GridClient client)
 {
     Log(message, level, client, null);
 }
示例#25
0
 /// <summary>
 /// Send a log message to the logging engine
 /// </summary>
 /// <param name="message">The log message</param>
 /// <param name="level">The severity of the log entry</param>
 /// <param name="client">Instance of the client</param>
 public static void Log(object message, Helpers.LogLevel level, SecondLife client)
 {
     Log(message, level, client, null);
 }
示例#26
0
 public static void LogFormat(string Message, Helpers.LogLevel Level, int Value)
 {
     LogFormat(Message, new[] { Value.ToString() });
 }
示例#27
0
 public DebugLogMessage(string message, Helpers.LogLevel level, DateTime tstamp)
 {
     this.message   = message;
     this.level     = level;
     this.timestamp = tstamp;
 }