public static void WithTimeLogging( this ILogging logging, string contextName, string origin, Action action, string activityName) { logging.Verbose(origin, "Started {0} for {1}", activityName, contextName); try { action(); } catch (Exception e) { logging.Write( new LogEntry { Severity = Severity.Error, Origin = origin, Message = e.Message }); } finally { logging.Verbose(origin, "Done {0} for {1}", activityName, contextName); } }
static void Main(string[] args) { //Logging.SetCreator(new ConsoleCreator()); //ILogging log = Logging.GetInstance(); //log.Verbose("Hello"); //Logging.SetCreator(new FileCreator()); //ILogging log = Logging.GetInstance(); //log.Verbose("Good evening"); Logging.SetCreator(new EmailCreator()); ILogging log = Logging.GetInstance(); log.Verbose("Good evening"); Console.ReadLine(); }