Esempio n. 1
0
 /// <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
 /// <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);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// prints to stdout; could write to a log window
        /// </summary>
        /// <param name="logLevel">
        /// The level of the message to log.
        /// </param>
        /// <param name="tag">
        /// A tag describing the the message to log.
        /// </param>
        /// <param name="message">
        /// The message to log.
        /// </param>
        /// <param name="args">
        /// Any arguments associated with the 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
 /// <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));
 }