Beispiel #1
0
 public virtual ICollection <ILoggerConfiguration> GetLoggerConfigurations(ICloudFoundryLoggerProvider provider)
 {
     if (provider == null)
     {
         _logger?.LogInformation("Unable to access Cloud Foundry Logging provider, log configuration unavailable");
         return(new List <ILoggerConfiguration>());
     }
     return(provider.GetLoggerConfigurations());
 }
Beispiel #2
0
        public virtual void SetLogLevel(ICloudFoundryLoggerProvider provider, string name, string level)
        {
            if (provider == null)
            {
                _logger?.LogInformation("Unable to access Cloud Foundry Logging provider, log level not changed");
                return;
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException(nameof(name));
            }

            if (string.IsNullOrEmpty(level))
            {
                throw new ArgumentException(nameof(level));
            }

            provider.SetLogLevel(name, LoggerLevels.MapLogLevel(level));
        }
Beispiel #3
0
        public virtual Dictionary <string, object> DoInvoke(ICloudFoundryLoggerProvider provider, LoggersChangeRequest request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (request != null)
            {
                SetLogLevel(provider, request.Name, request.Level);
            }
            else
            {
                AddLevels(result);
                var configuration = GetLoggerConfigurations(provider);
                Dictionary <string, LoggerLevels> loggers = new Dictionary <string, LoggerLevels>();
                foreach (var c in configuration)
                {
                    _logger.LogTrace("Adding " + c.ToString());
                    LoggerLevels lv = new LoggerLevels(c.ConfiguredLevel, c.EffectiveLevel);
                    loggers.Add(c.Name, lv);
                }
                result.Add("loggers", loggers);
            }

            return(result);
        }