public override async Task OnExceptionAsync(ExceptionContext context)
        {
            var details        = context.HttpContext.GetLoggingHttpContextDetails();
            var descriptor     = context.ActionDescriptor as ControllerActionDescriptor;
            var actionName     = descriptor?.ActionName;
            var controllerType = descriptor?.ControllerTypeInfo.UnderlyingSystemType;

            _loggerService.CreateLogger(controllerType, actionName);
            await _loggerService.LogError(context.Exception, details);
        }
 public UserAuthController(IAccountService accountService, ILoggerFactory loggerFactory, IAccessTokenService accessTokenService, ILoggerService loggerService, INotificationService notificationService,
                           UserManager <UserAccount> userManager, SignInManager <UserAccount> signInManager)
 {
     _accountService      = accountService;
     _accessTokenService  = accessTokenService;
     _notificationService = notificationService;
     _loggerService       = loggerService.CreateLogger(this);
     _signInManager       = signInManager;
     _userManager         = userManager;
 }
Пример #3
0
 public AdminAuthController(IAccountService accountService, IAccessTokenService accessTokenService, ILoggerService loggerService, INotificationService notificationService,
                            UserManager <AdministratorAccount> userManager, SignInManager <AdministratorAccount> signInManager, RoleManager <AdministratorRole> roleManager)
 {
     _accountService      = accountService;
     _accessTokenService  = accessTokenService;
     _notificationService = notificationService;
     _loggerService       = loggerService.CreateLogger(this);
     _signInManager       = signInManager;
     _userManager         = userManager;
     _roleManager         = roleManager;
 }
        public ScheduledBackgroundService(ILoggerService loggerService, IConfigurationService configurationService,
                                          IAccountService accountService, IRedisService redisService)
        {
            _loggerService = loggerService;
            _loggerService.CreateLogger <ScheduledBackgroundService>();
            _accountService = accountService;
            _database       = redisService.RedisCache;
            var serializer = new NewtonsoftSerializer();

            _cacheClient = new StackExchangeRedisCacheClient(_database.Multiplexer, serializer);
            var sysConfig   = configurationService.SystemConfiguration;
            var redisConfig = sysConfig.RedisOptions;

            _adminTokenPrefix    = redisConfig.AdminTokenPrefix;
            _userTokenPrefix     = redisConfig.UserTokenPrefix;
            ServiceConfiguration = new Dictionary <string, TimeSpan>();
            var schedulerOptions = sysConfig.SchedulerOptions;
            var services         = schedulerOptions.Services;

            foreach (var config in services)
            {
                var      serviceName = config.Name.ToLower();
                var      interval    = Convert.ToDouble(config.Interval);
                TimeSpan intervalType;
                switch (config.IntervalType.ToLower())
                {
                case "seconds":
                    intervalType = TimeSpan.FromSeconds(interval);
                    break;

                case "minutes":
                    intervalType = TimeSpan.FromMinutes(interval);
                    break;

                case "hours":
                    intervalType = TimeSpan.FromHours(interval);
                    break;

                case "days":
                    intervalType = TimeSpan.FromDays(interval);
                    break;
                }

                ServiceConfiguration[serviceName] = intervalType;
            }
        }
 public ServiceScheduler(ILoggerService loggerService, IScheduledBackgroundService scheduledBackgroundService)
 {
     _loggerService = loggerService;
     _loggerService.CreateLogger <ServiceScheduler>();
     _scheduledBackgroundService = scheduledBackgroundService;
 }
 public SpotifyClientProviderService(ILoggerService loggerService, SpotifyAccessConfiguration configuration)
 {
     this.serviceLogger = loggerService.CreateLogger();
     this.configuration = configuration;
 }
Пример #7
0
        public override async Task OnResultExecutionAsync(ResultExecutingContext context,
                                                          ResultExecutionDelegate next)
        {
            var details    = context.HttpContext.GetLoggingHttpContextDetails();
            var controller = context.Controller;
            var actionName = ((ControllerBase)controller).ControllerContext.ActionDescriptor.ActionName;

            _loggerService.CreateLogger(controller, actionName);

            if (context.Result is StatusCodeResult statusCodeResult)
            {
                await _loggerService.LogInformation(new { StatusCode = statusCodeResult.StatusCode, Result = (object)null }, details);
            }
            else
            {
                int?statusCode;
                var result = (ObjectResult)context.Result;
                if (context.ModelState.IsValid)
                {
                    if (result != null)
                    {
                        statusCode = result.StatusCode;
                        if (!(result.Value is IEnumerable <object>))
                        {
                            await _loggerService.LogInformation(new { StatusCode = statusCode, Result = result.Value },
                                                                details);
                        }
                        else
                        {
                            var valueObject = (IEnumerable <object>)result.Value;
                            var stringArray = valueObject.Flatten();
                            await _loggerService.LogInformation(new { StatusCode = statusCode, Result = stringArray },
                                                                details);
                        }
                    }
                }
                else
                {
                    context.Result = new BadRequestObjectResult(context.ModelState);
                    result         = (ObjectResult)context.Result;
                    if (result != null)
                    {
                        statusCode = result.StatusCode;
                        object[] valueObjectsArray;
                        if (result.Value is string)
                        {
                            valueObjectsArray = new object[] { new[] { result.Value } };
                        }
                        else
                        {
                            var dict = (Dictionary <string, object>)result.Value;
                            valueObjectsArray = dict.Values.ToArray();
                        }

                        var valuesList = new List <string>();
                        foreach (string[] value in valueObjectsArray)
                        {
                            valuesList.AddRange(value);
                        }

                        await _loggerService.LogInformation(new { StatusCode = statusCode, Result = valuesList },
                                                            details);
                    }
                }
            }
            //if (result?.StatusCode == StatusCodes.Status401Unauthorized || result?.StatusCode == StatusCodes.Status200OK)
            //{
            //     /* Message for these status codes are used only for logging purposes.  So, remove message sent to client. */
            //     if (!(result.Value is IEnumerable<object>))
            //     {
            //          result.Value = null;
            //     }
            //     else
            //     {
            //          var valueObject = (IEnumerable<object>)result.Value;
            //          valueObject.ToArray()[0] = null;
            //          result.Value = valueObject;
            //     }
            //     context.Result = result;
            //}

            // the actual action
            await next();

            // logic after the action goes here
        }
Пример #8
0
 public LoggerWrapper(ILoggerService loggerService, string name, IConfigurationRoot config)
 {
     _logger = loggerService.CreateLogger <LoggerWrapper>();
     _name   = name;
     _config = config;
 }
Пример #9
0
 public LoggerMiddleware(RequestDelegate next, ILoggerService loggerService)
 {
     _next   = next;
     _logger = loggerService.CreateLogger <LoggerMiddleware>();
 }
Пример #10
0
 public WeatherForecastController(ILoggerService logger)
 {
     Logger = logger.CreateLogger <WeatherForecastController>();
 }
Пример #11
0
 public SpotifyMetaInfoFetcherService(ILoggerService loggerService, ISpotifyClientProviderService clientProviderService)
 {
     this.serviceLogger         = loggerService.CreateLogger();
     this.clientProviderService = clientProviderService;
 }
Пример #12
0
        public HomeController(ILoggerService loggerService)
        {
            _logger = loggerService.CreateLogger <HomeController>();

            _logger.Log("HomeController");
        }
Пример #13
0
 public SpotifyPlaylistsManagerService(ILoggerService loggerService, ISpotifyClientProviderService clientProviderService)
 {
     this.serviceLogger         = loggerService.CreateLogger();
     this.clientProviderService = clientProviderService;
 }