public object FormatLogEntry(LoggingAction action, List <LogAttribute> attributes) { var logEntry = string.Empty; logEntry = string.Format( "{0}:", action); foreach (var attribute in attributes) { var value = string.Empty; if (attribute.Value == null) { value = GetDefaultValue(attribute.Name); } else { value = attribute.Value.ToString(); } logEntry += string.Format( " {0}=\"{1}\";", HttpUtility.HtmlEncode(attribute.Name), HttpUtility.HtmlEncode(value) ); } return(logEntry); }
public Parameters(T decoratedService, ILogger logger, LoggingAction beforeAction = null, LoggingAction afterAction = null, LoggingErrorAction errorAction = null) { DecoratedService = decoratedService; Logger = logger; BeforeAction = beforeAction ?? defaultBeforeAction; AfterAction = afterAction ?? defaultAfterAction; ErrorAction = errorAction ?? defaultErrorAction; }
private void WriteEntry(LoggingAction action, List <LogAttribute> attributes) { var msg = FormatProvider.FormatLogEntry( LoggingAction.Entry, attributes ).ToString(); WriteLine(msg); }
public static void put_watcher_sample(ElasticClient client) { // action var action = new LoggingAction("mylog") { Text = "some node is down", Level = LogLevel.Info }; ConditionContainer condition = new AlwaysCondition(); var my_http = new HttpInputRequest { Host = "localhost", Port = 9200, Path = "_cat/nodes", Method = HttpInputMethod.Get }; var input = new HttpInput { Request = my_http }; var hourly = new HourlySchedule(); int[] intNumbers = new int[] { 30 }; hourly.Minute = intNumbers; var trigger = new ScheduleContainer { Hourly = hourly }; var id = "status-check"; PutWatchRequest watchRequest = new PutWatchRequest(id) { Actions = action, Condition = condition, Input = input, Trigger = trigger }; PutWatchResponse response = client.Watcher.Put(watchRequest); Console.WriteLine("hello"); }
/// <summary> /// log any action and save data as xml object /// </summary> /// <typeparam name="T"></typeparam> /// <param name="_categoty"></param> /// <param name="_action"></param> /// <param name="OldData"></param> /// <param name="NewData"></param> /// <param name="_UserId"></param> /// <param name="RowId"></param> /// <returns></returns> public async Task LogActionData <T>(LoggingCategory _categoty, LoggingAction _action, T OldData, T NewData, Guid _UserId, string RowId) where T : class { var OData = SetDataToXML <T>(OldData); var NData = NewData != null?SetDataToXML <T>(NewData) : ""; var _LogData = new SystemLogging { LoggingAction = _action, LoggingCategory = _categoty, NewData = NData, ActionDate = DateTime.Now, OldData = OData, RowID = RowId, UserID = _UserId, }; await repository.AddAsync <SystemLogging>(_LogData); await repository.SaveChangesAsync(); }
/// <summary> /// Adds a delegate for configuring the provided <see cref="ILoggingBuilder"/>. This may be called multiple times. /// </summary> /// <param name="hostBuilder">The <see cref="IHostBuilder" /> to configure.</param> /// <param name="configureLogging">The delegate that configures the <see cref="ILoggingBuilder"/>.</param> /// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns> public static IHostBuilder ConfigureLogging(this IHostBuilder hostBuilder, LoggingAction configureLogging) { return(hostBuilder.ConfigureServices((context, collection) => collection.AddLogging(builder => configureLogging(builder)))); }
/// <summary> /// Log w/o waiting the invoke to finish. /// </summary> internal void Log(TraceLevel level, string message) { LoggingAction.BeginInvoke(level, message, null, null); //LoggingAction.Invoke(level, message); }