public LogEventsController() { Template.RegisterSafeType(typeof(DataTablesResultObject), obj => new Bauer.DotLiquidDropProxy(obj)); Template.RegisterSafeType(typeof(DataTableAjaxPostModel), obj => new Bauer.DotLiquidDropProxy(obj)); Template.RegisterSafeType(typeof(Column), obj => new Bauer.DotLiquidDropProxy(obj)); Template.RegisterSafeType(typeof(Search), obj => new Bauer.DotLiquidDropProxy(obj)); Template.RegisterSafeType(typeof(Order), obj => new Bauer.DotLiquidDropProxy(obj)); Get["/eventlog"] = _ => View["eventlog"]; Get["/api/logevents"] = parameters => { List <SimpleLogEntry> lst = new List <SimpleLogEntry>(); foreach (var item in Program.LogEvents) { var copy = new SimpleLogEntry(); copy.Date = item.TimeStamp.ToShortDateString(); copy.Time = item.TimeStamp.ToLongTimeString(); copy.Level = item.Level.Name; copy.Text = item.RenderedMessage; lst.Add(copy); } return(Response.AsJson(new DataObject { data = lst })); }; Get["/eventlog2"] = _ => View["eventlog2"]; Post["/api/logevents2"] = parameters => CustomServerSideSearchAction(parameters); }
public static void Main() { var baseEntry = new SimpleLogEntry() { Created = DateTime.Now, Message = "test" }; var simpleEntry = new SimpleLogEntry(baseEntry) { AdditionalInfo = "additional" }; var exceptionEntry = new ExceptionLogEntry(baseEntry) { ExceptionCode = 111 }; //it is possible to declare multiple visitors for particular hierarchy of objects // for example: PersistentLogEntryVisitors that allows to process LogEntries and save them to storage var visitor = new LogEntryVisitor(); visitor.ProcessLogEntry(simpleEntry); Assert.Contains("simple", visitor.State); visitor.ProcessLogEntry(exceptionEntry); Assert.Contains("exception", visitor.State); TestRunner.Print(); }
static void Main(string[] args) { ExceptionLogEntry exlogEntry = new ExceptionLogEntry(); SimpleLogEntry simpleLogEntry = new SimpleLogEntry(); var dbsaver = new DatabaseLogSaver(); dbsaver.SaveLogEntry(simpleLogEntry); dbsaver.SaveLogEntry(exlogEntry); Console.ReadLine(); }
public void ImportsEntryWithinSpecifiedTimeSpan() { // Arrange var logEntry = new SimpleLogEntry { EntryDateTime = DateTime.Now.AddDays(-5) }; // Assert Assert.IsTrue(_rule.ShouldImport(logEntry)); }
public void RejectsOldEntryWithLowSeverity() { // Arrange var logEntry = new SimpleLogEntry { EntryDateTime = DateTime.Now.AddDays(-10) }; // Assert Assert.IsFalse(_rule.ShouldImport(logEntry)); }
public void ImportsOldEntryWithHighSeverity() { // Arrange var logEntry = new SimpleLogEntry { EntryDateTime = DateTime.Now.AddDays(-10), Severity = Severity.Critical }; // Assert Assert.IsTrue(_rule.ShouldImport(logEntry)); }
private List <SimpleLogEntry> GetList() { List <SimpleLogEntry> lst = new List <SimpleLogEntry>(); foreach (var item in Bauer.Program.LogEvents) { var copy = new SimpleLogEntry(); copy.Date = item.TimeStamp.ToShortDateString(); copy.Time = item.TimeStamp.ToLongTimeString(); copy.Level = item.Level.Name; copy.Text = item.RenderedMessage; lst.Add(copy); } return(lst); }
public void Save(SimpleLogEntry simpleLogEntry) { Console.WriteLine("ElasticSearchLogSaver Save() " + simpleLogEntry.Message); }
public static void Run() { #region Adapter Console.WriteLine("-----------Adapter pattern-------------"); var simpleLogEntry = new SimpleLogEntry { Message = "simpleLogEntry", Severity = 2, Date = DateTime.Now }; var exceptionalLogEntry = new ExceptionLogEntry() { Message = "exceptional log entry", Severity = 5, Date = DateTime.Now, Exception = new Exception("Some exception message") }; ILogSaver sqlLogSaver = new SqlServerLogSaverAdapter(); sqlLogSaver.Save(simpleLogEntry); sqlLogSaver.Save(exceptionalLogEntry); ILogSaver elasticLogSaver = new ElasticSearchLogSaverAdapter(); elasticLogSaver.Save(simpleLogEntry); elasticLogSaver.Save(exceptionalLogEntry); Console.WriteLine(Environment.NewLine); Console.WriteLine(Environment.NewLine); #endregion #region Facade Console.WriteLine("-----------Facade pattern-------------"); var facade = new SqlServerFacade(); facade.ExecuteNonQuery("select * from all"); Console.WriteLine(Environment.NewLine); Console.WriteLine(Environment.NewLine); #endregion #region Decorator Console.WriteLine("-----------Decorator pattern -------------"); Console.WriteLine("-----------Throttling -------------"); var logSaver = new ThrottlingLogSaverDecorator(new ElasticLogSaver()); logSaver.SaveLogEntry("1242", simpleLogEntry); Console.WriteLine(Environment.NewLine); Console.WriteLine("-----------Trace -------------"); var traceLogSaver = new TraceServerDecorator(new ElasticLogSaver()); traceLogSaver.SaveLogEntry("12432", simpleLogEntry); Console.WriteLine(Environment.NewLine); Console.WriteLine("-----------Factory -------------"); var factLogSaver = LogSaverFactory.CrateLogSaver(); factLogSaver.SaveLogEntry("12432", simpleLogEntry); Console.WriteLine(Environment.NewLine); Console.WriteLine(Environment.NewLine); Console.WriteLine("-----------Composite Pattern -------------"); // Таким образом, клиентский код может поддерживать простые // компоненты-листья... var client = new Client(); Leaf leaf = new Leaf(); Console.WriteLine("Client: I get a simple component:"); client.ClientCode(leaf); // ...а также сложные контейнеры. Composite tree = new Composite(); Composite branch1 = new Composite(); branch1.Add(new Leaf()); branch1.Add(new Leaf()); Composite branch2 = new Composite(); branch2.Add(new Leaf()); tree.Add(branch1); tree.Add(branch2); Console.WriteLine("Client: Now I've got a composite tree:"); client.ClientCode(tree); Console.Write("Client: I don't need to check the components classes even when managing the tree:\n"); client.ClientCode2(tree, leaf); Console.WriteLine(Environment.NewLine); Console.WriteLine(Environment.NewLine); #endregion }
public void Create_WithSemicolonInStackElement_ThrowsException() { SimpleLogEntry.Create(Microsoft.Extensions.Logging.LogLevel.Information, new List <string> { "A", "B", "C;D" }, "Not a message"); }
private void SaveSimpleLogEntry(SimpleLogEntry logEntry) { }
void ILogEntryVisitor.Visit(SimpleLogEntry simpleLogEntry) { SaveSimpleLogEntry(simpleLogEntry); }
private void SaveSimpleLogEntry(SimpleLogEntry logEntry) { Console.WriteLine("SimpleLog saved"); }
private void SaveSimpleLogEntry(SimpleLogEntry simpleLogEntry) { throw new System.NotImplementedException(); }
public void Visit(SimpleLogEntry simpleLogEntry) { SaveSimpleLogEntry(simpleLogEntry); }
void ILogEntryVisitor.Visit(SimpleLogEntry simpleLogEntry) { State = $"LogEntryVisitor[{nameof(simpleLogEntry)}]"; }
public void Save(SimpleLogEntry simpleLogEntry) { // saves to es }