public LogViewModel(ILogStore logStore) { _logStore = logStore; Messenger.Default.Register<NotificationMessage<HttpResponse>>(this, async message=> await AddLogEntry(message.Content)); LoadOnlyForToday(); LoadData(); }
public LogFileService(ILogStore store) { Store = store ?? throw new ArgumentNullException(nameof(store)); }
public SunLoggerProvider(ILogStore logStore) { _logStore = logStore; }
/// <summary> /// Instantiate a new instance of the DefaultAuditSubscriber class. This constructor takes the primary store, fallback store and a loger. /// </summary> /// <param name="store">The primary store to write to.</param> /// <param name="fallbackStore">The fallback store to write to.</param> /// <param name="logger">The logger.</param> public DefaultAuditSubscriber(ILogStore <RabbitAuditMessage> store, ILogStore <RabbitAuditMessage> fallbackStore, ILogger logger) { _store = store; _fallbackStore = fallbackStore; _logger = logger; }
private async Task LoadLogsAsync(ILogStore logStore) { var hasPath = !string.IsNullOrEmpty(logStore.Path); if (hasPath) { SetOverlayState(OverlayState.Loading); } var aggregator = new LogAggregator(); var treeBuilder = new LogTreeBuilder(); List <LogItem> logs = null; await Task.Run(async() => logs = await ReadLogsAsync(logStore).ConfigureAwait(false)); while (logs == null) { Thread.Sleep(50); } _logs = aggregator.Aggregate(logs); _lastLogPath = logStore.Path; // Generate a data table and bind the date-time client to it. dateTimeChartRangeControlClient1.DataProvider.DataSource = _logs; // Specify data members to bind the client. dateTimeChartRangeControlClient1.DataProvider.ArgumentDataMember = nameof(RangeDatasourceItem.TimeStampLocal); dateTimeChartRangeControlClient1.DataProvider.ValueDataMember = nameof(RangeDatasourceItem.ItemCount); dateTimeChartRangeControlClient1.DataProvider.SeriesDataMember = nameof(RangeDatasourceItem.State); dateTimeChartRangeControlClient1.DataProvider.TemplateView = new BarChartRangeControlClientView() { }; dateTimeChartRangeControlClient1.PaletteName = "Solstice"; var allStates = Enum.GetValues(typeof(LogItem.State)).OfType <LogItem.State>().ToArray(); var timestamps = logs.Select(l => l.TimeStampLocal).Distinct(); var rangeSource = timestamps.SelectMany(localTime => { return(allStates.Select(state => new RangeDatasourceItem { TimeStampLocal = localTime, State = state, ItemCount = _logs.Count(l => l.TimeStampLocal == localTime && l.AccumulatedState >= state) })); }); dateTimeChartRangeControlClient1.DataProvider.DataSource = rangeSource; SetControlVisiblityByContext(); if (_logs.Any()) { SetOverlayState(OverlayState.None); } else { SetOverlayState(OverlayState.Empty); } }
public static async Task OnSchemaAddedAsync(this IEnumerable <IOntologyEventHandler> handlers, ILogStore store, Schema schema, CancellationToken cancellationToken = default) { var pending = TaskPool.Get(); try { foreach (var handler in handlers) { var task = handler.OnSchemaAddedAsync(store, schema, cancellationToken); if (!task.IsReal()) { continue; } if (task.IsCompleted || task.IsCanceled || task.IsFaulted) { continue; } pending.Add(task); } if (pending.Count > 0) { await Task.WhenAll(pending); } } finally { TaskPool.Return(pending); } }
public JobLogViewComponent(IJobStore jobStore, ILogStore logStore) { _jobStore = jobStore; _logStore = logStore; }
//Dependencies: // Server implementation might be looking for UserIdentity and AppIdentity. // 1) define common subsystem or // 2) require developer to configure DI on both ends. public GuidIdLogger(ILogStore logStore) => this.logStore = logStore;
public FusionSession(IFusionService fusionService, ILogStore store) { FusionService = fusionService ?? throw new ArgumentNullException(nameof(fusionService)); Store = store ?? throw new ArgumentNullException(nameof(store)); }
public EventConsumer(string identifier, ILogStore logStore) : base() { _identifier = identifier; _logStore = logStore; }
public SyncModule(IAuthenticationProvider authenticationProvider, ISyncStore store, IReflectionStore reflectionStore, ILogStore log) : base(authenticationProvider, "/sync") { this.Post["/"] = parameters => { try { var user = this.CurrentUser; var dto = this.Bind <SynchronizationDto>(); var sync = store.Add(dto); return(this.Response.AsJson(sync)); } catch (Exception e) { return(this.ResponseFromException(e)); } }; this.Get["/"] = parameters => { try { var user = this.CurrentUser; DynamicDictionary q = this.Request.Query; Dictionary <string, string> filters = q.ToDictionary().ToDictionary(t => t.Key, t => t.Value.ToString()); var result = store.GetAll(filters); return(this.Response.AsJson(result)); } catch (Exception e) { return(this.ResponseFromException(e)); } }; this.Get["/{id}"] = parameters => { try { var user = this.CurrentUser; string id = parameters.id; var dto = store.GetById(id); return(this.Response.AsJson(dto)); } catch (Exception e) { return(this.ResponseFromException(e)); } }; this.Get["/{id}/reflections"] = parameters => { try { var user = this.CurrentUser; string syncId = parameters.id; var sync = store.GetById(syncId); int take; var reflections = Int32.TryParse(this.Request.Query["take"].ToString(), out take) ? reflectionStore.GetBySynchronization(sync, take) : reflectionStore.GetBySynchronization(sync); return(this.Response.AsJson(reflections)); } catch (Exception e) { return(this.ResponseFromException(e)); } }; this.Put["/{id}/status"] = parameters => { try { var user = this.CurrentUser; var dto = this.Bind <UpdateStatusDto>(); if (dto != null && dto.Status.HasValue) { try { string id = parameters.id; store.UpdateStatus(id, dto.Status.Value); return(HttpStatusCode.OK); } catch (StatusNotChangedException) { return(this.Negotiate .WithReasonPhrase(ReasonPhrases.StatusAlreadyUpdated) .WithStatusCode(HttpStatusCode.Conflict)); } } else { return(this.Negotiate .WithReasonPhrase(ReasonPhrases.UpdateStatusBadRequest) .WithStatusCode(HttpStatusCode.BadRequest)); } } catch (Exception e) { return(this.ResponseFromException(e)); } }; this.Put["{id}/logs"] = parameters => { try { var user = this.CurrentUser; var dto = this.Bind <SyncLogDto>(); if (dto != null && !string.IsNullOrEmpty(dto.Text)) { try { string syncId = parameters.id; var sync = store.GetById(syncId); log.LogSync(sync, dto.Text); return(HttpStatusCode.OK); } catch (StatusNotChangedException) { return(this.Negotiate .WithReasonPhrase("Log bad request.") .WithStatusCode(HttpStatusCode.BadRequest)); } } else { return(this.Negotiate .WithReasonPhrase("Log bad request.") .WithStatusCode(HttpStatusCode.BadRequest)); } } catch (Exception e) { return(this.ResponseFromException(e)); } }; this.Get["{id}/logs"] = parameters => { try { var user = this.CurrentUser; try { string syncId = parameters.id; var sync = store.GetById(syncId); if (sync == null) { return(this.Negotiate .WithReasonPhrase("Sync not found.") .WithStatusCode(HttpStatusCode.NotFound)); } var l = log.Get(sync); if (l == null) { return(this.Negotiate .WithReasonPhrase("Log not found.") .WithStatusCode(HttpStatusCode.NotFound)); } return(this.Response.AsJson(l)); } catch (StatusNotChangedException) { return(this.Negotiate .WithReasonPhrase("Log bad request.") .WithStatusCode(HttpStatusCode.BadRequest)); } } catch (Exception e) { return(this.ResponseFromException(e)); } }; }
public DefaultAppLogStore(ILogStore logStore) { Guard.NotNull(logStore, nameof(logStore)); this.logStore = logStore; }
public LogStoreSequenceProvider(ILogStore store) { _store = store; }
public CollectModule(IAppConfigurationManager config, IValidator <LogRecord> logRecordValidator, ILogStore logStore) { Post["/collect", true] = async(x, ct) => { var logrec = this.Bind <LogRecord>(new BindingConfig { BodyOnly = true }); var validationResult = logRecordValidator.Validate(logrec); if (!validationResult.IsValid) { return("VALIDATION ERROR"); } logrec.ApplicationPath = logrec.ApplicationPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); var app = await config.FindAppAsync(logrec.ApplicationPath); if (app == null) { app = new Application { IsExcluded = true, Path = logrec.ApplicationPath }; await config.AddOrUpdateAppAsync(app); } if (!app.IsExcluded) { await logStore.AddLogRecordAsync(logrec); await logStore.UpdateApplicationStatusAsync( CreateApplicationStatus(logrec)); } return("OK"); }; Post["/collectall", true] = async(x, ct) => { var logrecs = this.Bind <LogRecord[]>(new BindingConfig { BodyOnly = true }); var logsToSave = new List <LogRecord>(logrecs.Length); foreach (var logrec in logrecs) { var validationResult = logRecordValidator.Validate(logrec); if (validationResult.IsValid) { logrec.ApplicationPath = logrec.ApplicationPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); // add new application to the configuration as excluded (it could be later renamed or unexcluded) var app = await config.FindAppAsync(logrec.ApplicationPath); if (app == null) { app = new Application { IsExcluded = true, Path = logrec.ApplicationPath }; await config.AddOrUpdateAppAsync(app); } if (!app.IsExcluded) { logsToSave.Add(logrec); } else { logger.TraceEvent(TraceEventType.Verbose, 0, "Log record for the application '{0}' was not stored as the application is excluded."); } } else { if (logger.Switch.ShouldTrace(TraceEventType.Warning)) { logger.TraceEvent(TraceEventType.Warning, 0, "Validation error(s) occured when saving a logrecord: {0}, errors: {1}", logrec, validationResult.Errors); } } } if (logsToSave.Count > 0) { await logStore.AddLogRecordsAsync(logsToSave); await logStore.UpdateApplicationStatusesAsync(CreateApplicationStatusesList(logsToSave)); } return("OK"); }; }
public override Task OnSchemaAddedAsync(ILogStore store, Schema schema, CancellationToken cancellationToken = default) { return(Task.Run(() => _changeProvider.OnChanged(), cancellationToken)); }
public Task OnSchemaAddedAsync(ILogStore store, Schema schema, CancellationToken cancellationToken = default) { return(_handlers.OnSchemaAddedAsync(store, schema, cancellationToken)); }
public BucketLogProvider(ILogStore logStore, IHttpContextAccessor httpContextAccessor, string projectName) { _logStore = logStore; _projectName = projectName; _httpContextAccessor = httpContextAccessor; }
public CaptureLogInterceptor(ILogStore logStore, IUserProvider userProvider) { _logStore = logStore; _userProvider = userProvider; }
public ApplicationGridModule(GlobalConfig globals, IAppConfigurationManager appconf, ILogStore logStore) { if (globals.IsAuthenticationEnabled()) { this.RequiresAuthentication(); } Get["/", true] = async(x, ct) => { ApplicationGridModel model = null; if (DefaultCacheTimeInSeconds != 0) { model = cache["appstats"] as ApplicationGridModel; } if (model == null) { var applicationStatuses = await logStore.GetApplicationStatusesAsync(DateTime.UtcNow.AddMinutes(-15)); var allApplications = await appconf.GetAppsAsync(); var activeServers = new SortedSet <string>(); var activeApplications = new Dictionary <string, Application>(); var activeApplicationStatuses = new SortedDictionary <string, IDictionary <string, LastApplicationStatus> >(); foreach (var appStatus in applicationStatuses) { activeServers.Add(appStatus.Server); var app = allApplications.FirstOrDefault(a => string.Equals(a.Path, appStatus.ApplicationPath, StringComparison.InvariantCultureIgnoreCase)); if (app != null && !app.IsExcluded) { if (!activeApplications.ContainsKey(app.Path)) { activeApplications.Add(app.Path, app); } IDictionary <string, LastApplicationStatus> applicationStatusPerServer; if (!activeApplicationStatuses.TryGetValue(app.Path, out applicationStatusPerServer)) { applicationStatusPerServer = new Dictionary <string, LastApplicationStatus>(StringComparer.OrdinalIgnoreCase); activeApplicationStatuses.Add(app.Path, applicationStatusPerServer); } applicationStatusPerServer.Add(appStatus.Server, appStatus); } } // for the rest of the applications foreach (var app in allApplications) { if (!app.IsExcluded) { if (!activeApplications.ContainsKey(app.Path)) { activeApplications.Add(app.Path, app); } if (!activeApplicationStatuses.ContainsKey(app.Path)) { activeApplicationStatuses.Add(app.Path, new Dictionary <string, LastApplicationStatus>(StringComparer.OrdinalIgnoreCase)); } } } model = new ApplicationGridModel { LastUpdateTime = DateTime.Now, Servers = activeServers.ToArray(), Applications = activeApplications, ApplicationStatuses = activeApplicationStatuses }; if (DefaultCacheTimeInSeconds != 0) { cache.Set("appstats", model, new CacheItemPolicy() { AbsoluteExpiration = DateTimeOffset.UtcNow.AddSeconds(DefaultCacheTimeInSeconds) }); } } return(View["ApplicationGrid.cshtml", model]); }; Get["/apps", true] = async(x, ct) => { // gets applications for which we have received the logs return(View["Applications", (await appconf.GetAppsAsync()).Where(app => !app.IsHidden).Select( app => { app.DaysToKeepLogs = app.DaysToKeepLogs ?? AppSettings.DefaultNoOfDaysToKeepLogs; return app; })]); }; }
public LogsController(ILogStore logStore) { this.logStore = logStore; }
public ApplicationConfModule(GlobalConfig globals, IAppConfigurationManager appconf, ILogStore logStore, IValidator <Application> appvalidator, IValidator <ApplicationServerConfig> appconfvalidator) { if (globals.IsAuthenticationEnabled()) { this.RequiresAuthentication(); } Post["conf/appname", true] = async(x, ct) => { return(await UpdateAppPropertiesAsync(appconf, appvalidator, this.Bind <Application>(), "Name")); }; Post["conf/appmaintenance", true] = async(x, ct) => { return(await UpdateAppPropertiesAsync(appconf, appvalidator, this.Bind <Application>(), "DaysToKeepLogs")); }; Post["conf/appexclusion", true] = async(x, ct) => { return(await UpdateAppPropertiesAsync(appconf, appvalidator, this.Bind <Application>(), "IsExcluded")); }; Post["conf/apphidden", true] = async(x, ct) => { // we will mark it as excluded also var app = this.Bind <Application>(); app.IsExcluded = true; return(await UpdateAppPropertiesAsync(appconf, appvalidator, app, new[] { "IsHidden", "IsExcluded" })); }; Get["conf/appsrvconfig/{apppath?}", true] = async(x, ct) => { IEnumerable <Application> apps; if (x.apppath != null) { apps = new[] { await appconf.FindAppAsync(Application.GetPathFromBase64Key((String)x.apppath)) }; } else { // get all non-hidden applications apps = (await appconf.GetAppsAsync()).Where(app => !app.IsHidden); } // and send back their configuration return(await appconf.GetAppConfigsAsync(apps.Select(app => app.Path).ToArray())); }; Get["conf/appsrvconfigs", true] = async(x, ct) => { var activeAppPaths = (await appconf.GetAppsAsync()).Where( app => !app.IsHidden && !app.IsExcluded).Select(app => app.Path).ToArray(); return(Response.AsJson(await appconf.GetAppConfigsAsync(activeAppPaths))); }; }
public LogMaintenance(IAppConfigurationManager config, ILogStore logStore) { this.config = config; this.logStore = logStore; }
public UserNotificationFactory(IClock clock, ILogStore logstore, IUserNotificationUrl url) { this.clock = clock; this.logstore = logstore; this.url = url; }
public WebhookChannel(IHttpClientFactory httpClientFactory, ISemanticLog log, ILogStore logStore, IUserNotificationQueue userNotificationQueue, IUserNotificationStore userNotificationStore) { this.httpClientFactory = httpClientFactory; this.log = log; this.logStore = logStore; this.userNotificationQueue = userNotificationQueue; this.userNotificationStore = userNotificationStore; }
public QueryLogInterceptor(ILogStore logStore, IUserProvider userProvider) { _logStore = logStore; _userProvider = userProvider; }