12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using Rac.Models;
- namespace Rac.Common
- {
- public abstract class BaseService
- {
- public abstract void Start();
- public abstract void Stop();
- public event EventHandler<LogEventArgs> Log = delegate { };
- protected void LogDebug(string message)
- {
- OnMessage(new LogEventArgs { Level = LogLevel.Debug, Log = message });
- }
- protected void LogTrace(string message)
- {
- OnMessage(new LogEventArgs { Level = LogLevel.Trace, Log = message });
- }
- protected void LogInfo(string message)
- {
- OnMessage(new LogEventArgs { Level = LogLevel.Info, Log = message });
- }
- protected void LogWarning(string message)
- {
- OnMessage(new LogEventArgs { Level = LogLevel.Warning, Log = message });
- }
- protected void LogError(string message)
- {
- OnMessage(new LogEventArgs { Level = LogLevel.Error, Log = message });
- }
- protected void LogFatal(string message)
- {
- OnMessage(new LogEventArgs { Level = LogLevel.Fatal, Log = message });
- }
- protected virtual void OnMessage(LogEventArgs e)
- {
- Log(this, e);
- }
- }
- }
|