コード例 #1
0
 /// <summary>
 /// Log an event or exception.
 /// </summary>
 /// <param name="LogWriter">Log writer object used for documenting events.</param>
 /// <param name="sessionId">The current session's unique ID.</param>
 /// <param name="connectionId">The current connection's unique ID.</param>
 /// <param name="message">The message to log.</param>
 /// <param name="minimalLogLevel">The minimal log level needed for the message to be logged.</param>
 /// <param name="currentLogLevel">The session's current log level.</param>
 public static void Log(FreyaStreamWriter LogWriter, string sessionId, string connectionId, string message, LogLevel minimalLogLevel, LogLevel currentLogLevel)
 {
     if ((int)currentLogLevel >= (int)minimalLogLevel)
     {
         try
         {
             if (LogWriter != null)
             {
                 if (LogWriter.textLogEn)
                 {
                     lock (LogWriter)
                     {
                         LogWriter.Write("[" + DateTime.Now + "]\t" + sessionId + "\t" + connectionId + "\t" + minimalLogLevel.ToString().ToUpper() + "\t" + message + (message.EndsWith("\r\n") ? "" : "\r\n"));
                         LogWriter.Flush();
                     }
                 }
                 LogWriter.radioSend(connectionId + " " + message + (message.EndsWith("\r\n") ? "" : "\r\n"));
             }
         }
         catch (Exception ex) { Console.WriteLine(ex.Message); }
         Console.WriteLine("[" + DateTime.Now + "]\t" + sessionId + "\t" + connectionId + "\t" + minimalLogLevel.ToString().ToUpper() + "\t" + message + (message.EndsWith("\r\n") ? "" : "\r\n"));
     }
 }
コード例 #2
0
        /// <summary>
        /// Log an event or exception.
        /// </summary>
        /// <param name="LogWriter">Log writer object used for documenting events.</param>
        /// <param name="sessionId">The current session's unique ID.</param>
        /// <param name="message">The message to log.</param>
        /// <param name="minimalLogLevel">The minimal log level needed for the message to be logged.</param>
        /// <param name="currentLogLevel">The session's current log level.</param>
        public static void Log(FreyaStreamWriter LogWriter, string sessionId, string message, LogLevel minimalLogLevel, LogLevel currentLogLevel)
        {
            if ((int)currentLogLevel >= (int)minimalLogLevel)
            {
                if (LogWriter != null)
                {
                    if (LogWriter.textLogEn)
                    {
                        lock (LogWriter)
                        {
                            LogWriter.Write("[" + DateTime.Now + "]\t" + sessionId + "\t\t" + minimalLogLevel.ToString().ToUpper() + "\t" + message + (message.EndsWith("\r\n") ? "" : "\r\n"));
                            LogWriter.Flush();
                        }
                    }

                    if (!LogWriter.radioSend(message + (message.EndsWith("\r\n") ? "" : "\r\n")).Equals(FEnv.RADIO_OK))
                    {
                        LogWriter.Write($"Error sending message to UI. SMTP Radio UI port :{LogWriter?.radioClient?.GetPort()}");
                    }
                }
                Console.WriteLine("[" + DateTime.Now + "]\t" + sessionId + "\t\t" + minimalLogLevel.ToString().ToUpper() + "\t" + message + (message.EndsWith("\r\n") ? "" : "\r\n"));
            }
        }