public ConfigurationViewModel(ILoggerConfiguration configuration)
 {
     _configuration            = configuration;
     _redmineApiKey            = configuration.RedmineApiKey;
     _redmineUrl               = configuration.RedmineUrl;
     _saveConfigurationCommand = new RelayCommand(SaveConfiguration, CanSaveConfiguration);
 }
Example #2
0
        /// <summary>
        ///     Configure this logger
        /// </summary>
        /// <param name="loggerConfiguration"></param>
        public override void Configure(ILoggerConfiguration loggerConfiguration)
        {
            // Copy all values from the ILoggerConfiguration
            base.Configure(loggerConfiguration);

            // Test if it's a IFileLoggerConfiguration
            if (!(loggerConfiguration is IFileLoggerConfiguration fileLoggerConfiguration))
            {
                return;
            }

            // Copy all values from the IFileLoggerConfiguration
            if (string.IsNullOrEmpty(fileLoggerConfiguration.Processname))
            {
#if !_PCL_
                SetProcessname(fileLoggerConfiguration);
#else
                throw new ArgumentNullException(nameof(fileLoggerConfiguration.Processname));
#endif
            }

            ArchiveHistory         = fileLoggerConfiguration.ArchiveHistory;
            ArchiveCompress        = fileLoggerConfiguration.ArchiveCompress;
            ArchiveCount           = fileLoggerConfiguration.ArchiveCount;
            ArchiveDirectoryPath   = fileLoggerConfiguration.ArchiveDirectoryPath;
            ArchiveExtension       = fileLoggerConfiguration.ArchiveExtension;
            ArchiveFilenamePattern = fileLoggerConfiguration.ArchiveFilenamePattern;
            DirectoryPath          = fileLoggerConfiguration.DirectoryPath;
            Extension       = fileLoggerConfiguration.Extension;
            FilenamePattern = fileLoggerConfiguration.FilenamePattern;
            MaxBufferSize   = fileLoggerConfiguration.MaxBufferSize;
            PreFormat       = fileLoggerConfiguration.PreFormat;
            Processname     = fileLoggerConfiguration.Processname;
            WriteInterval   = fileLoggerConfiguration.WriteInterval;
        }
Example #3
0
        public override void UpdateProperties(ILoggerConfiguration config)
        {
            base.UpdateProperties(config);

            UpdateHighProperties(HighProperties, ObjEnd);
            UpdateMedProperties(MedProperties, ObjEnd);
            UpdateLowProperties(LowProperties, ObjEnd);
        }
Example #4
0
        public override void SetProperties(ILoggerConfiguration config)
        {
            base.SetProperties(config);

            SetHighProperties(HighProperties, Obj);
            SetMedProperties(MedProperties, Obj);
            SetLowProperties(LowProperties, Obj);
        }
Example #5
0
 public RGLogger(
     IRGWebApiClientFactory arg0,
     ILoggerConfiguration arg1
     )
 {
     field0 = arg0;
     field1 = arg1;
 }
Example #6
0
        public LocalizationManager(ILoggerConfiguration loggerConfiguration, Logger logger, Assembly assembly = null)
        {
            var language = loggerConfiguration.Language;

            localizationFile     = GetLocalizationFile(language, assembly ?? Assembly.GetExecutingAssembly());
            coreLocalizationFile = GetLocalizationFile(language, Assembly.GetExecutingAssembly());
            this.logger          = logger;
        }
Example #7
0
        /// <summary>
        /// Constructor, sets the parameters
        /// </summary>
        /// <param name="loggerConfiguration">Logger Configuration Factory</param>
        /// <param name="consoleAccess">Console Factory</param>
        /// <param name="dataAccess">DB Data Factory</param>
        /// <param name="fileAccess">File Factory</param>
        public JobLogger(ILoggerConfiguration loggerConfiguration, IConsoleAccess consoleAccess, IDataAccess dataAccess, IFileAccess fileAccess)
        {
            this._dataAccess = dataAccess;
            this._consoleAccess = consoleAccess;
            this._fileAccess = fileAccess;

            this._loggerConfiguration = loggerConfiguration;
        }
Example #8
0
        public void SetNextRunDate(ILoggerConfiguration config, DateTime current)
        {
            if (current.TimeOfDay >= config.Daily || !_scheduleHelper.IsWorkingDay(current.DayOfWeek))
            {
                current = _scheduleHelper.GetNextWorkingDay(current);
            }

            NextRunDate = current.Date + config.Daily;
        }
Example #9
0
        public Service(ILoggerConfiguration config, IScheduleHelper scheduleHelper, ApiHost api)
        {
            _config         = config;
            _scheduleHelper = scheduleHelper;
            _api            = api;

            InitializeComponent();
            ServiceConfiguration();
        }
Example #10
0
        public MemoryLogger(ILoggerConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            _configuration = configuration;
        }
Example #11
0
        public virtual void SetProperties(ILoggerConfiguration config)
        {
            if (!IsInitialized)
            {
                throw new Exception("Logging Information Initialization has not occurred");
            }

            SafeTry.IgnoreException(() => Machine     = System.Environment.MachineName);
            SafeTry.IgnoreException(() => Application = AppSettings.Name);
        }
Example #12
0
 public LogItem(ILoggerConfiguration config, LogLevel logLevel, EventId eventId, string name, object?state, Exception?exception)
 {
     TimeStamp     = DateTime.UtcNow;
     Configuration = config;
     Level         = logLevel;
     Id            = eventId;
     Name          = name;
     State         = state;
     Exception     = exception;
 }
Example #13
0
 /// <inheritdoc />
 public virtual void Configure(ILoggerConfiguration loggerConfiguration)
 {
     if (loggerConfiguration == null)
     {
         return;
     }
     LogLevel       = loggerConfiguration.LogLevel;
     UseShortSource = loggerConfiguration.UseShortSource;
     LogLineFormat  = loggerConfiguration.LogLineFormat;
     DateTimeFormat = loggerConfiguration.DateTimeFormat;
 }
Example #14
0
        public MemoryWBackupLogger(ILoggerConfiguration configuration)
        {
            // make sure we have configuration
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            // keep internal configuration
            _configuration = configuration;
        }
Example #15
0
        public LoggerRegistry(ILoggerConfiguration config)
        {
            Scan(a =>
            {
                a.TheCallingAssembly();
                a.WithDefaultConventions();
                a.LookForRegistries();

                a.AddAllTypesOf <IController>();
            });

            For <ILoggerConfiguration>().Use(config);
            For <IScheduleHelper>().Use(new ScheduleHelper(config));
        }
Example #16
0
        public void SetNextRunDate(ILoggerConfiguration config, DateTime current)
        {
            if (current.TimeOfDay >= config.Weekly)
            {
                current = _scheduleHelper.GetNextWorkingDay(current);
            }

            while (current.DayOfWeek != config.WeeklyDay)
            {
                current = _scheduleHelper.GetNextWorkingDay(current);
            }

            NextRunDate = current.Date + config.Weekly;
        }
Example #17
0
        public SqlLogger(ILoggerConfiguration configuration)
        {
            // if no config, throw exception
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            // set config
            _configuration = configuration;

            // create mapper
            _mapper = new Mapper();
        }
Example #18
0
 public virtual async Task Initialize(ILoggerConfiguration config)
 {
     InitializeResult(TraceEventType.Information, RequestData.DisplayUrl);
     // Need to save off anything from the request/context objects here in the main thread
     SetRoute();
     SetMethod();
     SetHeaders();
     SetQueryString();
     SetFormData();
     if (config.Include(RequestDataKey))
     {
         ContentData = await RequestData.ContentData();
     }
     SetBrowser();
 }
Example #19
0
        public override void SetProperties(ILoggerConfiguration config)
        {
            Message = Ex.GetFullMessage();
            base.SetProperties(config);

            if (MessageOnly)
            {
                return;
            }

            StackTrace = Ex.GetStackTrace();
            HighProperties.Add(StackTraceKey, StackTrace);
            MedProperties.Add(SourceKey, Ex.Source);
            LowProperties.Add(TitleKey, Title);
        }
Example #20
0
        /// <summary>
        /// ToString
        /// </summary>
        /// <param name="loggerConfiguration">ILoggerConfiguration</param>
        /// <returns></returns>
        public string ToString(ILoggerConfiguration loggerConfiguration)
        {
            var stringBuilder = new StringBuilder(Timestamp.ToString(loggerConfiguration?.DateTimeFormat ?? "yyyy-MM-dd HH:mm:ss.fff"));

            stringBuilder
            .Append(' ')
            .Append(LogLevel)
            .Append(' ')
            .Append(loggerConfiguration.UseShortSource ? Source.ShortSource : Source.Source)
            .Append(':')
            .Append(Method)
            .Append('(')
            .Append(Line.ToString())
            .Append(')');
            return(stringBuilder.ToString());
        }
Example #21
0
        public override void SetProperties(ILoggerConfiguration config)
        {
            base.SetProperties(config);

            HighProperties.Add(ConnectionKey, CnnName);

            if (!config.Include(ParametersKey))
            {
                return;
            }

            SetSqlParams();
            var hideKeys = config.HideKeys();

            MedProperties.Add(ParametersKey, SqlParams.AsString(hideKeys));
        }
Example #22
0
 /// <summary>
 /// Note that I'm only injecting ILoggerConfiguration, and all the others are being looked up via Service Locator.
 /// This seemed like an easier pattern to use instead of having a large interface listing into constructor
 /// </summary>
 public Logger(
     ILoggerConfiguration config,
     ILoggers loggers,
     IServiceProvider provider,
     IAlert alert,
     LongRunningInformation longRunningInfo,
     HttpResponseInformation httpResponseInfo,
     IApplicationSettings app,
     IEmail email
     )
 {
     Config           = config;
     Loggers          = loggers;
     Provider         = provider;
     Alert            = alert;
     LongRunningInfo  = longRunningInfo;
     HttpResponseInfo = httpResponseInfo;
     App       = app;
     EmailImpl = email;
 }
Example #23
0
        public TestFixture()
        {
            config = new LoggerConfiguration();

            _controllers = new List <IController>()
            {
                // Add any new controllers here for the test fixture
                new ScheduleController(config)
            };

            _api = new ApiHost(config, _controllers);

            _host = WebApp.Start(config.LoggerServiceEndpoint, app =>
            {
                _api.Configure(app);
                foreach (var controller in _controllers)
                {
                    controller.Configure(app);
                }
            });
        }
        public override void UpdateProperties(ILoggerConfiguration config)
        {
            base.UpdateProperties(config);

            if (StatusCode == 0)
            {
                return;
            }

            HighProperties.Add(StatusCodeKey, StatusCode.ToString());

            if (!config.Include(ResultKey))
            {
                return;
            }

            SetResponse();
            var hideKeys = config.HideKeys();

            MedProperties.Add(ResultKey, Response.AsString(hideKeys));
        }
Example #25
0
        public void SetNextRunDate(ILoggerConfiguration config, DateTime current)
        {
            current = current.Add(config.InstantInterval);

            if (current.TimeOfDay > config.DayEnd)
            {
                current = _scheduleHelper.GetNextWorkingDay(current);
                current = current.Date + config.DayStart;
            }
            else if (!_scheduleHelper.IsWorkingDay(current.DayOfWeek))
            {
                current = _scheduleHelper.GetNextWorkingDay(current);
            }


            if (current.TimeOfDay < config.DayStart)
            {
                current = current.Date + config.DayStart;
            }

            NextRunDate = current;
        }
Example #26
0
        public static void InitializeLogging(ILoggerConfiguration config)
        {
            string path1 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");

            Serilog.LoggerConfiguration loggerConfiguration = new Serilog.LoggerConfiguration().MinimumLevel.Debug().Enrich
                                                              .WithProperty("softwareName", (object)config.SoftwareName, false).Enrich.FromLogContext().WriteTo
                                                              .ColoredConsole(LogEventLevel.Verbose,
                                                                              "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}", (IFormatProvider)null)
                                                              .WriteTo.RollingFile(Path.Combine(path1, config.SoftwareName + ".log"), LogEventLevel.Verbose,
                                                                                   "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}",
                                                                                   (IFormatProvider)null, new long?(1073741824L), new int?(31));

            Log.Logger = loggerConfiguration.CreateLogger();

            Log.ForContext <ServiceBase>().Information("Configuration: {@config}", (object)config);

            AppDomain.CurrentDomain.UnhandledException += (UnhandledExceptionEventHandler)((sender, e) =>
            {
                Exception exceptionObject = e.ExceptionObject as Exception;
                Log.ForContext <ServiceBase>().Error(exceptionObject, exceptionObject.Message);
            });
        }
Example #27
0
        public override void SetProperties(ILoggerConfiguration config)
        {
            base.SetProperties(config);

            if (!string.IsNullOrWhiteSpace(Route))
            {
                HighProperties.Add(RouteKey, Route);
            }

            if (!string.IsNullOrWhiteSpace(HttpMethod))
            {
                HighProperties.Add(MethodKey, HttpMethod);
            }

            if (!config.Include(RequestDataKey))
            {
                return;
            }

            SetData();
            var hideKeys = config.HideKeys();

            MedProperties.Add(RequestDataKey, DataNvc.AsString(hideKeys));
        }
Example #28
0
        public override void SetProperties(ILoggerConfiguration config)
        {
            base.SetProperties(config);
            var hideKeys = config.HideKeys();

            // Most are set in Initialize
            if (!string.IsNullOrWhiteSpace(Route))
            {
                HighProperties.Add(RouteKey, Route);
            }
            if (!string.IsNullOrWhiteSpace(HttpMethod))
            {
                HighProperties.Add(MethodKey, HttpMethod);
            }
            if (config.Include(HeadersKey))
            {
                MedProperties.Add(HeadersKey, GetHeaders());
            }
            if (config.Include(QueryStringKey))
            {
                MedProperties.Add(QueryStringKey, QueryString.AsString(hideKeys));
            }
            if (config.Include(FormKey))
            {
                MedProperties.Add(FormKey, FormData.AsString(hideKeys));
            }
            if (config.Include(RequestDataKey))
            {
                SetRequestData(); // Raw info was saved in Initialize
                MedProperties.Add(RequestDataKey, RequestUserData.AsString(hideKeys));
            }
            if (!string.IsNullOrWhiteSpace(Browser) && config.Include(BrowserKey))
            {
                LowProperties.Add(BrowserKey, Browser);
            }
        }
        public Logger(ILoggerConfiguration loggerConfiguration)
        {
            _loggerConfiguration = loggerConfiguration ?? throw new ArgumentNullException(nameof(loggerConfiguration));

            Initialise();
        }
Example #30
0
 public ApiHost(ILoggerConfiguration config, IEnumerable <IController> controller)
 {
     _config      = config;
     _controllers = controller.ToList();
 }
Example #31
0
 public TraceLoggerService(ILoggerConfiguration loggerConfiguration)
 {
     _loggerConfiguration = loggerConfiguration;
 }