using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Kanilus.Framework.Logging { public enum MessageType { NA, Log, Debug, Warning, Alert } public class LoggerEventArgs : EventArgs { public string Caption = string.Empty; public string Body = string.Empty; public MessageType MessageType = MessageType.NA; public uint Code = 0; public LoggerEventArgs(string caption,string body,MessageType type,uint code) : base() { Caption = caption; Body = body; MessageType = type; Code = code; } } public static class LogManager { public static event EventHandler NewLogEntry; public static void Debug(string caption) { Entry(caption, string.Empty, MessageType.Debug, 0); } public static void Debug(string caption, string body) { Entry(caption, body, MessageType.Debug, 0); } public static void Debug(string caption, uint code) { Entry(caption, string.Empty, MessageType.Debug, code); } public static void Debug(string caption,string body, uint code) { Entry(caption, body, MessageType.Debug, code); } public static void Log(string caption) { Entry(caption, string.Empty, MessageType.Log, 0); } public static void Log(string caption, string body) { Entry(caption, body, MessageType.Log, 0); } public static void Log(string caption, uint code) { Entry(caption, string.Empty, MessageType.Log, code); } public static void Log(string caption, string body, uint code) { Entry(caption, body, MessageType.Log, code); } public static void Entry(string caption, string body, MessageType type, uint code) { raiseEvent(caption, body, type, code); } private static void raiseEvent(string caption, string body,MessageType type, uint code) { if (NewLogEntry != null) { NewLogEntry(null,new LoggerEventArgs(caption,body,type,code)); } } } }