Esempio n. 1
0
File: Log.cs Progetto: vebin/madb
 /// <summary>
 /// Formats a log message.
 /// </summary>
 /// <param name="logLevel"></param>
 /// <param name="tag"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public static string GetLogFormatString(LogLevel.LogLevelInfo logLevel, string tag, string message)
 {
     long totalmsec = DateTime.Now.ToUnixEpoch();
     var sec = (totalmsec / 60000) % 60;
     var msec = (totalmsec / 1000) % 60;
     return string.Format($"{sec:00}:{msec:00} {logLevel.Letter}/{tag}: {message}\n");
 }
Esempio n. 2
0
File: Log.cs Progetto: vebin/madb
 /// <summary>
 /// Prints a log message.
 /// </summary>
 /// <param name="logLevel"></param>
 /// <param name="tag"></param>
 /// <param name="message"></param>
 public static void Write(LogLevel.LogLevelInfo logLevel, string tag, string message)
 {
     Console.Write(GetLogFormatString(logLevel, tag, message));
 }
Esempio n. 3
0
File: Log.cs Progetto: vebin/madb
        /// <summary>
        /// prints to stdout; could write to a log window
        /// </summary>
        /// <param name="logLevel"></param>
        /// <param name="tag"></param>
        /// <param name="message"></param>
        private static void WriteLine(LogLevel.LogLevelInfo logLevel, string tag, string message, params object[] args)
        {
            if (logLevel.Priority >= Level.Priority)
            {
                string formattedMessage = message;

                if (args != null && args.Length > 0)
                {
                    formattedMessage = string.Format(formattedMessage, args);
                }

                if (LogOutput != null)
                {
                    LogOutput.Write(logLevel, tag, formattedMessage);
                }
                else
                {
                    Write(logLevel, tag, formattedMessage);
                }
            }
        }
Esempio n. 4
0
File: Log.cs Progetto: vebin/madb
 /// <summary>
 /// Outputs a log message and attempts to display it in a dialog.
 /// </summary>
 /// <param name="logLevel">The log level</param>
 /// <param name="tag">The tag associated with the message.</param>
 /// <param name="message">The message to output.</param>
 public static void LogAndDisplay(LogLevel.LogLevelInfo logLevel, string tag, string message)
 {
     if (LogOutput != null)
     {
         LogOutput.WriteAndPromptLog(logLevel, tag, message);
     }
     else
     {
         WriteLine(logLevel, tag, message);
     }
 }