コード例 #1
0
        /// <summary>
        /// Writes an event in the Event Log.
        /// </summary>
        /// <param name="message">The message to be logged. </param>
        /// <param name="severity">The severity of the event. </param>
        /// <param name="timeBetweenEntries"></param>
        private static void Write(string message, ESeverityLevel severity, TimeSpan timeBetweenEntries)
        {
            string sourceNameSpace = Process.GetCurrentProcess().MainModule.ModuleName;

            WriteLog(Settings.Default.EventLogName, sourceNameSpace, message, severity,
                     timeBetweenEntries);
        }
コード例 #2
0
        /// <summary>
        /// Writes an event in the Event Log (and also to the log file found
        /// in the application folder)
        /// </summary>
        /// <param name="logName">Name of the log to write</param>
        /// <param name="source">Source of the log message</param>
        /// <param name="message">The message to be logged.</param>
        /// <param name="severity">The severity of the event.</param>
        /// <param name="timeBetweenEntries"></param>
        private static void WriteLog(string logName, string source, string message,
                                     ESeverityLevel severity, TimeSpan timeBetweenEntries)
        {
            if (SourceExists(source, logName))
            {
                if (SeverityLevel != ESeverityLevel.SeverityNone &&
                    (timeBetweenEntries == TimeSpan.Zero ||
                     !ShouldSuppressLog(message, timeBetweenEntries)))
                {
                    message = string.Format("[{0}] {1} ", AppVersion, message);
                    switch (severity)
                    {
                    case ESeverityLevel.SeverityError:
                        LogToFile.Error(message);
                        EventLog.WriteEntry(source, message, EventLogEntryType.Error, 1, 1);
                        break;

                    case ESeverityLevel.SeverityWarning:
                        LogToFile.Warning(message);
                        EventLog.WriteEntry(source, message, EventLogEntryType.Warning, 1, 1);
                        break;

                    case ESeverityLevel.SeverityInfo:
                        LogToFile.Info(message);
                        EventLog.WriteEntry(source, message, EventLogEntryType.Information, 1, 1);
                        break;
                    }
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Logs the specified exception.
 /// </summary>
 /// <param name="ex">The exception. </param>
 /// <param name="severity">The severity. </param>
 public static void Exception(Exception ex, ESeverityLevel severity)
 {
     if (ex == null)
     {
         Write(Resources.LogEventNullException, ESeverityLevel.SeverityWarning,
               TimeSpan.Zero);
     }
     else
     {
         Write(ex.ToString(), severity, TimeSpan.Zero);
     }
 }
コード例 #4
0
        public Ticket(string title, string description, ETicketStatus status, ETicketType type, ESeverityLevel level, Guid idClient, Address address)
        {
            Title       = title;
            Description = description;
            Status      = status;
            Level       = level;
            Type        = type;
            IdClient    = idClient;
            Address     = address;

            AddNotifications(new Contract()
                             .Requires()
                             .HasMinLen(Title, 3, "Title", "Título deve ter mais de 3 caracteres")
                             .HasMaxLen(Title, 60, "Title", "Título deve ter menos de 60 caracteres")
                             .HasMinLen(Description, 3, "Description", "Título deve ter mais de 3 caracteres")
                             .HasMaxLen(Description, 1024, "Description", "Título deve ter menos de 60 caracteres")
                             );
        }
コード例 #5
0
ファイル: DomainLogger.cs プロジェクト: Guzikowski/MovieShelf
        private void ProcessLogMessage(string message, Exception exception, ESeverityLevel level)
        {
            switch (level)
            {
                case ESeverityLevel.Debug:
                    if (_logger.IsDebugEnabled)
                        _logger.Debug(message, exception);
                    break;

                case ESeverityLevel.Information:
                    if (_logger.IsInfoEnabled)
                        _logger.Info(message, exception);
                    break;

                case ESeverityLevel.Warning:
                    if (_logger.IsWarnEnabled)
                        _logger.Warn(message, exception);
                    break;

                case ESeverityLevel.Error:
                    if (_logger.IsErrorEnabled)
                        _logger.Error(message, exception);
                    break;

                case ESeverityLevel.Fatal:
                    if (_logger.IsFatalEnabled)
                        _logger.Fatal(message, exception);
                    break;

                default:
                    if (_logger.IsErrorEnabled)
                        _logger.Error(message, exception);
                    break;

            }
        }
コード例 #6
0
ファイル: DomainLogger.cs プロジェクト: Guzikowski/MovieShelf
        public void Log(Exception exception, string contextMessage, ESeverityLevel level)
        {
            string message = String.Empty;

            if (!String.IsNullOrEmpty(contextMessage))
                message = contextMessage + "\r\n";

            if (exception != null)
            {
                foreach (DictionaryEntry item in exception.Data)
                {
                    message += string.Format("{0} : {1}\r\n", item.Key, item.Value);
                }

                Exception ex = exception;
                while (ex != null)
                {
                    message += String.Format("{0}\r\n{1}\r\n", ex.Message, ex.StackTrace);
                    ex = ex.InnerException;
                }
            }
            Console.WriteLine(message);
            ProcessLogMessage(message, exception, level);
        }
コード例 #7
0
 static LogEvent()
 {
     SeverityLevel = ESeverityLevel.SeverityWarning;
 }
コード例 #8
0
ファイル: DomainLogger.cs プロジェクト: Guzikowski/MovieShelf
 public void LogMessage(string message, ESeverityLevel severity = ESeverityLevel.Debug)
 {
     Log(null, message, severity);
 }
コード例 #9
0
ファイル: DomainLogger.cs プロジェクト: Guzikowski/MovieShelf
 public void LogException(Exception exception, ESeverityLevel severity = ESeverityLevel.Error)
 {
     Log(exception, null, severity);
 }