From 1a6dc0b3d3da14cb99a64d72b7ebf711b4dfacc3 Mon Sep 17 00:00:00 2001 From: cfb10 <busca_carlos@yahoo.com> Date: Wed, 10 Jul 2013 17:42:13 +0100 Subject: [PATCH 1/2] Custom error message --- src/ServiceStack.Logging.EventLog/EventLogger.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ServiceStack.Logging.EventLog/EventLogger.cs b/src/ServiceStack.Logging.EventLog/EventLogger.cs index ab6617c..29e2b4e 100644 --- a/src/ServiceStack.Logging.EventLog/EventLogger.cs +++ b/src/ServiceStack.Logging.EventLog/EventLogger.cs @@ -10,7 +10,7 @@ namespace ServiceStack.Logging.EventLog public class EventLogger : ILog { private const string NEW_LINE = "\r\n\r\n"; - private const string ERROR_MSG = "An error occurred in the application: {0}\r\nException: {1}"; + //private const string ERROR_MSG = "An error occurred in the application: {0}\r\nException: {1}"; private readonly string eventLogSource; private readonly string eventLogName; @@ -20,7 +20,7 @@ public class EventLogger : ILog /// </summary> /// <param name="eventLogName">Name of the event log.</param> /// <param name="eventLogSource">The event log source.</param> - public EventLogger(string eventLogName, string eventLogSource) + public EventLogger(string eventLogName, string eventLogSource, string eventLogMessage) { if (string.IsNullOrEmpty(eventLogName)) { @@ -30,8 +30,13 @@ public EventLogger(string eventLogName, string eventLogSource) { throw new ArgumentNullException("eventLogSource"); } + if (string.IsNullOrEmpty(eventLogMessage)) + { + throw new ArgumentNullException("eventLogMessage"); + } this.eventLogName = eventLogName; this.eventLogSource = eventLogSource; + this.eventLogMessage = eventLogMessage; } public bool IsDebugEnabled { get { return true; } } @@ -75,7 +80,7 @@ private void Write(object message, Exception execption, EventLogEntryType eventL } eventLogger.Source = eventLogName; - eventLogger.WriteEntry(String.Format(ERROR_MSG, eventLogSource, sb), eventLogType); + eventLogger.WriteEntry(String.Format(eventLogMessage, eventLogSource, sb), eventLogType); } /// <summary> From e43940c27dc47eb81512256f6844579b640771d3 Mon Sep 17 00:00:00 2001 From: cfb10 <busca_carlos@yahoo.com> Date: Thu, 11 Jul 2013 11:05:46 +0100 Subject: [PATCH 2/2] Parameter is now optional I just fix what i did and now the parameter is optional. Thanks --- src/ServiceStack.Logging.EventLog/EventLogger.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ServiceStack.Logging.EventLog/EventLogger.cs b/src/ServiceStack.Logging.EventLog/EventLogger.cs index 29e2b4e..4c9c04f 100644 --- a/src/ServiceStack.Logging.EventLog/EventLogger.cs +++ b/src/ServiceStack.Logging.EventLog/EventLogger.cs @@ -10,7 +10,7 @@ namespace ServiceStack.Logging.EventLog public class EventLogger : ILog { private const string NEW_LINE = "\r\n\r\n"; - //private const string ERROR_MSG = "An error occurred in the application: {0}\r\nException: {1}"; + private const string ERROR_MSG = "An error occurred in the application: {0}\r\nException: {1}"; private readonly string eventLogSource; private readonly string eventLogName; @@ -20,7 +20,8 @@ public class EventLogger : ILog /// </summary> /// <param name="eventLogName">Name of the event log.</param> /// <param name="eventLogSource">The event log source.</param> - public EventLogger(string eventLogName, string eventLogSource, string eventLogMessage) + /// <param name="eventLogMessage">The event message.</param> + public EventLogger(string eventLogName, string eventLogSource, string eventLogMessage = ERROR_MSG) { if (string.IsNullOrEmpty(eventLogName)) {