コード例 #1
0
 public void Warning(string text)
 {
     if (LogOptions.EnableWarning)
     {
         OnLogWarning?.Invoke(text);
     }
 }
コード例 #2
0
        /// <summary>
        /// Log a warning event to the event log. If we can't write to the event log, nothing happens.
        /// </summary>
        /// <param name="text">The event text</param>
        /// <param name="pid">The event program source.</param>
        /// <param name="code">The event code</param>
        public static void LogWarning(string text, string pid, int code)
        {
            if (PhazeXLog.writeFileLog)
            {
                try
                {
                    if (Filename != null)
                    {
                        StreamWriter sw = new StreamWriter(Filename, true, Encoding.ASCII);
                        DateTime     dt = DateTime.Now;
                        sw.Write("[  Warning  ] [" + dt.ToShortDateString() + " " + dt.ToLongTimeString() + "] ");
                        sw.Write(text + newLine);
                        sw.Close();
                    }
                }
                catch
                {
                }
            }

#if !PocketPC
            if (WriteEventLog)
            {
                try
                {
                    EventLog.WriteEntry(pid, text, EventLogEntryType.Warning, code);
                }
                catch
                {
                    // don't do anything -- this was our last resort
                }
            }
#endif
            if (OnLogWarning != null)
            {
                OnLogWarning.Invoke(text, pid, code);
            }
        }
コード例 #3
0
 /// <summary>
 /// Logs a warning.
 /// </summary>
 /// <param name="warningCode">The warning code.</param>
 /// <param name="file">The file associated with the message.</param>
 /// <param name="lineNumber">The line number within the associated file.</param>
 /// <param name="message">The message to log.</param>
 public static void LogWarning(string warningCode, string file, int lineNumber, string message)
 {
     OnLogWarning.Invoke(warningCode, file, lineNumber, message);
 }