public void Initialize() { // Set the LogWriter for the static Logger class Logger.SetLogWriter(new LogWriterFactory().Create()); _target = new LoggingManager(); }
public HomeController(IAdvertisementRepository advertisementRepository, IProductRepository productRepository, ICollectionRepository collectionRepository, ILoggingManager loggingManager) { _advertisementRepository = advertisementRepository; _productRepository = productRepository; _collectionRepository = collectionRepository; _loggingManager = loggingManager; }
public PrimeController( IMapper mapper, IMediator mediator, ILinksService linksService, ILoggingManager loggingManager, PolicyConfiguration policyConfiguration) { _mapper = mapper; _mediator = mediator; _linksService = linksService; _loggingManager = loggingManager; _policyConfiguration = policyConfiguration; _circuitBreakerPolicy = Policy .Handle <TaskCanceledException>() .CircuitBreakerAsync(policyConfiguration.CircuitBreakerAllowedExceptions, TimeSpan.FromMinutes(_policyConfiguration.CircuitBreakerShutdownDurationInMinutes), (ex, t) => { _loggingManager.LogFatal("Circuit broken!"); }, () => { _loggingManager.LogInformation("Circuit Reset!"); }); }
public FindNextPrimeCommandHandler( ILoggingManager loggingManager, IPrimeLinkRepository primeLinkRepository, ConnectionStrings connectionStrings) : base(connectionStrings) { _loggingManager = loggingManager; _primeLinkRepository = primeLinkRepository; }
public CheckNumberIsPrimeCommandHandler( ILoggingManager loggingManager, ICalculationRepository calculationRepository, ConnectionStrings connectionStrings) : base(connectionStrings) { _loggingManager = loggingManager; _calculationRepository = calculationRepository; }
public TimerQueueService(IOptions <BotSettings> botSettings, MixerConstellationService mixerService, ILoggingManager loggingManager, PlatformService platformServices, IStatisticsManager statisticsManager, GuildInteractionService guildServices, FileService fileService) { _botSettings = botSettings.Value; _mixerService = mixerService; _loggingManager = loggingManager; _platformServices = platformServices; _statisticsManager = statisticsManager; _guildServices = guildServices; _fileService = fileService; }
public LogEasyWindow() { InitializeComponent(); logMg = this.GetComponent <ILoggingManager>(); logMg.Logs.All((log) => { logBox.AppendText(log.ToFormatedString() + "\n"); return(true); }); logBox.ScrollToEnd(); logMg.Logs.CollectionChanged += Logs_CollectionChanged; }
public AuthController( ILoggingManager _loggingManager, IHttpContextAccessor _httpContextAccessor, IUserApplication userApp, AppDBContext context, IConfiguration configuration) { this.loggingManager = _loggingManager; this.httpContextAccessor = _httpContextAccessor; this.userApp = userApp; this.context = context; this.configuration = configuration; }
public async void LogMessage_CreateModelsStoreInDatabasePullFromDatabaseConvertToDtos_DtosShouldContainCorrectValues() { DependencyInjectionConfig.Init(); // Clear the mock database ILoggingManager logManager = ServiceLocator.Current.GetInstance <ILoggingManager>(); await logManager.DeleteAll(); // Log models to the mock database LogUtils.LogMessage(Enums.LogSeverity.INFO, "My message"); LogUtils.LogMessage(Enums.LogSeverity.WARNING, "My message", "Additional info"); LogUtils.LogMessage(Enums.LogSeverity.ERROR, ""); //// Wait for async IO operations //await Task.Delay(1000); // Pull models from the mock database List <LogSQLiteModel> logSqliteModels = await logManager.GetLogs(10); Assert.Equal(3, logSqliteModels.Count); // Convert models to DTOs IEnumerable <LogDTO> logDtos = logSqliteModels.Select(x => new LogDTO(x)); //Check that DTOs correspond with arguments to LogMessage() foreach (LogDTO logDto in logDtos) { if (logDto.Severity == Enums.LogSeverity.INFO.ToString()) { Assert.Equal("My message", logDto.Description); } else if (logDto.Severity == Enums.LogSeverity.WARNING.ToString()) { Assert.Equal("My message", logDto.Description); Assert.Equal("Additional info (GPS: Mock version)", logDto.AdditionalInfo); } else if (logDto.Severity == Enums.LogSeverity.ERROR.ToString()) { Assert.Equal("", logDto.Description); } else { throw new Exception("At least one of the ifs is expected to be true"); } } }
public PullKeysTests() { DependencyInjectionConfig.Init(); string zipDirectory = ServiceLocator.Current.GetInstance <IFileSystem>().CacheDirectory; if (!Directory.Exists(zipDirectory)) { Directory.CreateDirectory(zipDirectory); } _helper = new ZipDownloaderHelper(); _preferences = ServiceLocator.Current.GetInstance <IPreferences>(); _logManager = ServiceLocator.Current.GetInstance <ILoggingManager>(); _developerTools = ServiceLocator.Current.GetInstance <IDeveloperToolsService>(); _preferences.Clear(); _logManager.DeleteAll(); _developerTools.ClearAllFields(); }
public static async void SendAllLogs() { UpdateCorrelationId(null); ILoggingManager manager = ServiceLocator.Current.GetInstance <ILoggingManager>(); try { bool allLogsSent = false; while (!allLogsSent) { List <LogSQLiteModel> logs = await manager.GetLogs(_numLogsToSendAtATime); if (logs == null || !logs.Any()) { break; } // Try to post logs to the server List <LogDTO> dto = logs.Select(l => new LogDTO(l)).ToList(); bool success = await(new LoggingService()).PostAllLogs(dto); // If posting succeeded, delete them if (success) { await manager.DeleteLogs(logs); } // Else, we must try to send them another time. // Also make sure we don't store too many logs because sending keeps failing else { DeleteLogsIfTooMany(); break; } allLogsSent = logs.Count < _numLogsToSendAtATime; } } catch (Exception e) { System.Diagnostics.Debug.Print($"{nameof(LogUtils)}.{nameof(SendAllLogs)}: Failed to send logs. Wiping DB to prevent deadlock"); System.Diagnostics.Debug.Print(e.ToString()); await manager.DeleteAll(); } }
private static async void DeleteLogsIfTooMany() { ILoggingManager manager = ServiceLocator.Current.GetInstance <ILoggingManager>(); bool tooManyPersistedLogs = true; while (tooManyPersistedLogs) { // GetLogs gives the earliest logs List <LogSQLiteModel> logs = await manager.GetLogs(_maxNumOfPersistedLogsOnSendError * 2); tooManyPersistedLogs = logs.Count() > _maxNumOfPersistedLogsOnSendError; if (tooManyPersistedLogs) { int atLeastNLogsTooMany = logs.Count() - _maxNumOfPersistedLogsOnSendError; List <LogSQLiteModel> logsToDelete = logs.Take(atLeastNLogsTooMany).ToList(); await manager.DeleteLogs(logsToDelete); } } }
public ProvisioningHandler( IObjectBuilder objectBuilder, ITaskService taskService, IService <HistoryLog> historyLogService, ILoggingManager loggingManager, IUserIdentity userIdentity, IUnitOfWork unitOfWork) { if (objectBuilder == null) { throw new ArgumentNullException(nameof(objectBuilder)); } if (taskService == null) { throw new ArgumentNullException(nameof(taskService)); } if (historyLogService == null) { throw new ArgumentNullException(nameof(historyLogService)); } if (loggingManager == null) { throw new ArgumentNullException(nameof(loggingManager)); } if (userIdentity == null) { throw new ArgumentNullException(nameof(userIdentity)); } if (unitOfWork == null) { throw new ArgumentNullException(nameof(unitOfWork)); } _objectBuilder = objectBuilder; _taskService = taskService; _historyLogService = historyLogService; _loggingManager = loggingManager; _userIdentity = userIdentity; _unitOfWork = unitOfWork; }
public ProvisioningHandlerManager(ITaskService taskService, IObjectBuilder objectBuilder, ILoggingManager loggingManager) { if (taskService == null) { throw new ArgumentNullException(nameof(taskService)); } if (objectBuilder == null) { throw new ArgumentNullException(nameof(objectBuilder)); } if (loggingManager == null) { throw new ArgumentNullException(nameof(loggingManager)); } _taskService = taskService; _objectBuilder = objectBuilder; _loggingManager = loggingManager; }
public OperationsHandlerManager(ITaskService taskService, IService <HistoryLog> historyLogService, IParameterService parameterService, IObjectBuilder objectBuilder, ILoggingManager loggingManager, IUserIdentity userIdentity) { if (taskService == null) { throw new ArgumentNullException(nameof(taskService)); } if (historyLogService == null) { throw new ArgumentException(nameof(historyLogService)); } if (parameterService == null) { throw new ArgumentException(nameof(parameterService)); } if (objectBuilder == null) { throw new ArgumentNullException(nameof(objectBuilder)); } if (loggingManager == null) { throw new ArgumentNullException(nameof(loggingManager)); } if (userIdentity == null) { throw new ArgumentNullException(nameof(userIdentity)); } _taskService = taskService; _historyLogService = historyLogService; _parameterService = parameterService; _objectBuilder = objectBuilder; _loggingManager = loggingManager; _userIdentity = userIdentity; }
public async void LogException_CreateModelsStoreInDatabasePullFromDatabaseConvertToDtos_DtosShouldContainCorrectValues() { // Clear the mock database ILoggingManager logManager = ServiceLocator.Current.GetInstance <ILoggingManager>(); await logManager.DeleteAll(); // Log models to the mock database LogUtils.LogException(Enums.LogSeverity.INFO, new Exception("Hello"), "My context description"); LogUtils.LogException(Enums.LogSeverity.WARNING, new Exception("Goodbye"), "Context decription", "Additional info"); // Pull models from the mock database List <LogSQLiteModel> logSqliteModels = await logManager.GetLogs(10); Assert.Equal(2, logSqliteModels.Count); // Convert models to DTOs IEnumerable <LogDTO> logDtos = logSqliteModels.Select(x => new LogDTO(x)); // Check that DTOs correspond with arguments to LogMessage() foreach (LogDTO logDto in logDtos) { if (logDto.Severity == Enums.LogSeverity.INFO.ToString()) { Assert.Equal("Hello", logDto.ExceptionMessage); } else if (logDto.Severity == Enums.LogSeverity.WARNING.ToString()) { // (GPS: Mock version) is added in the Logdetails constructor Assert.Equal("Additional info (GPS: Mock version)", logDto.AdditionalInfo); } else { throw new Exception("At least one of the ifs is expected to be true"); } } }
public CepContext(IConfigurationRoot config, DbContextOptions options, ILoggingManager logger) : base(options) { _config = config; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="Logger" /> class. /// </summary> /// <param name="name">The name.</param> /// <param name="getLogLevel">The get log level.</param> /// <param name="loggingManager">The logging manager.</param> internal Logger(string name, Func<TraceEventType, LogLevel> getLogLevel, ILoggingManager loggingManager) { this.name = name; this.getLogLevel = getLogLevel; this.loggingManager = loggingManager; }
public ReadingsController(IRepositoryWrapper repoWrapper, ILoggingManager loggingManager, IMapper mapper) { _repoWrapper = repoWrapper; _loggingManager = loggingManager; _mapper = mapper; }
public AccountController(ILoggingManager loggingManager) { this.loggingManager = loggingManager; }
public ManageController(ILoggingManager loggingManager) { this.loggingManager = loggingManager; }
/// <summary> /// Creates a new ILogger instance of the given name. /// </summary> /// <param name="name">The name.</param> /// <param name="loggingManager">The logging manager.</param> /// <returns>A logger isntance</returns> public ILogger Create(string name, ILoggingManager loggingManager) { return new Logger(name, getLogLevel, loggingManager); }
public LoggingCollectorServerHandler(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _logger = serviceProvider.GetService <ILogger <LoggingCollectorServerHandler> >(); _loggingManager = serviceProvider.GetService <ILoggingManager>(); }
public async void LogApiError_CreateModelsStoreInDatabasePullFromDatabaseConvertToDtos_DtosShouldContainCorrectValues() { // Clear the mock database ILoggingManager logManager = ServiceLocator.Current.GetInstance <ILoggingManager>(); await logManager.DeleteAll(); // Log apiResponse1 string urlPrefix = Conf.URL_PREFIX; ApiResponse apiResponse1 = new ApiResponse(urlPrefix + "HELLO!", HttpMethod.Get); apiResponse1.StatusCode = 200; IEnumerable <ExposureKeyModel> temporaryExposureKeys = new List <ExposureKeyModel>() { new ExposureKeyModel(new byte[5], DateTimeOffset.FromUnixTimeSeconds(1234), TimeSpan.FromHours(24), RiskLevel.Medium), new ExposureKeyModel(new byte[5], DateTimeOffset.FromUnixTimeSeconds(1234), TimeSpan.FromHours(24), RiskLevel.Medium), new ExposureKeyModel(new byte[5], DateTimeOffset.FromUnixTimeSeconds(1234), TimeSpan.FromHours(24), RiskLevel.Medium), }; string redactedKeysJson = RedactedTekListHelper.CreateRedactedTekList(temporaryExposureKeys); LogUtils.LogApiError(Enums.LogSeverity.INFO, apiResponse1, false, redactedKeysJson); //Added Mockversion to test if version is set correctly in the Logdevicedetails redactedKeysJson += " (GPS: Mock version)"; // Log apiResponse2 ApiResponse apiResponse2 = new ApiResponse(urlPrefix + "GOODBYE!", HttpMethod.Get); apiResponse2.StatusCode = 201; LogUtils.LogApiError(Enums.LogSeverity.WARNING, apiResponse2, true); // Pull the two log models from the mock database List <LogSQLiteModel> logSqliteModels = await logManager.GetLogs(10); Assert.Equal(2, logSqliteModels.Count); // Convert the models to DTOs IEnumerable <LogDTO> logDtos = logSqliteModels.Select(x => new LogDTO(x)); // Check that the DTOs contain the expected values foreach (LogDTO logDto in logDtos) { // apiReponse1 string apiVersion = $"/v{Conf.APIVersion}/"; if (logDto.Severity == Enums.LogSeverity.INFO.ToString()) { Assert.Equal(apiVersion + "HELLO!", logDto.Api); Assert.Equal(200, logDto.ApiErrorCode); // We expect AdditionalInfo to consist of redactedKeysJson, after it's been processed with RedactText Assert.Equal(RedactText(redactedKeysJson), logDto.AdditionalInfo); // This part is just to double check redaction of key data works // Before redaction, the key data is a byte array of size 5, which is shown as "AAAAAAA=" // After redaction we do not want this to be in the string string nonRedactedKeysJson = JsonConvert.SerializeObject(temporaryExposureKeys, BaseWebService.JsonSerializerSettings); Assert.Contains("AAAAAAA=", nonRedactedKeysJson); Assert.DoesNotContain("AAAAAAA=", redactedKeysJson); } // apiResponse2 else if (logDto.Severity == Enums.LogSeverity.WARNING.ToString()) { Assert.Equal(apiVersion + "GOODBYE!", logDto.Api); Assert.Equal(201, logDto.ApiErrorCode); } // Should never be reached else { throw new Exception("At least one of the ifs is expected to be true"); } } }
private void InitLogSystem(ILoggingManager loggingManager) { loggingManager.Initialize(); }
public UploadDIagnosisKeysHelperTests() { DependencyInjectionConfig.Init(); _logManager = ServiceLocator.Current.GetInstance <ILoggingManager>(); _logManager.DeleteAll(); }
public ChangeLogController(IChangeLogBusinessService service, ILoggingManager loggingManager) { this.service = service; this.logger = loggingManager; }
public InstrumentationUnitTest() { var kernel = NinjectBootstrapper.Get(); this.LoggingManager = kernel.Get <ILoggingManager>(); }
public EventHandlerBase(AbstractRepository data, ILoggingManager loggingManager) : base(data, loggingManager) { // Initialize generic class }