Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SeriLogger"/> class.
        /// </summary>
        /// <param name="name">Name of the logger</param>
        /// <exception cref="ActivationException">if there are errors resolving the service instance.</exception>
        public SeriLogger(string name)
        {
            if (this.loggerConfigurator == null)
            {
                this.loggerConfigurator = ServiceLocator.Current.GetInstance <ILoggerConfigurator>();
            }

            this.logger = this.loggerConfigurator.GetLogger(name: name);
        }
        /// <summary>
        /// Creates new Logger with ILoggerConfigurator.
        /// </summary>
        /// <param name="configurator">ILoggerConfigurator object</param>
        /// <returns>Instance of new Logger</returns>
        public ILogger GetLogger(ILoggerConfigurator configurator)
        {
            Logger logger = new Logger(configurator)
            {
                IsActive = true
            };

            this.Loggers.Add(logger);
            return(logger);
        }
Esempio n. 3
0
        public static ILoggerConfigurator UseSqlServer(this ILoggerConfigurator configurator, string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentException(nameof(connectionString));
            }

            LogDataContext context = new LogDataContext(connectionString);

            ILogRepository logRepository = new LogRepository(context);

            ILoggerProvider provider = new SqlServerProvider(logRepository);

            configurator.SetProvider(provider);

            return(configurator);
        }
Esempio n. 4
0
 /// <summary>
 /// Closes the logger instance and flushes it.
 /// </summary>
 public void CloseAndFlush()
 {
     this.loggerConfigurator.Dispose();
     this.loggerConfigurator = null;
 }
Esempio n. 5
0
 /// <summary>
 /// Changes ILoggerConfigurator of Logger
 /// </summary>
 /// <param name="configurator">ILoggerConfigurator object</param>
 public void ChangeConfigurator(ILoggerConfigurator configurator)
 {
     this.configurator = configurator;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Logger"/> class.
 /// Sets ILoggerConfigurator instance.
 /// </summary>
 /// <param name="configurator">ILoggerConfigurator object</param>
 protected internal Logger(ILoggerConfigurator configurator)
 {
     this.configurator = configurator;
 }