コード例 #1
0
ファイル: TashAccessor.cs プロジェクト: aspenlaub/TashClient
 public TashAccessor(IDvinRepository dvinRepository, ISimpleLogger simpleLogger, ILogConfiguration logConfiguration, IMethodNamesFromStackFramesExtractor methodNamesFromStackFramesExtractor)
 {
     DvinRepository   = dvinRepository;
     _SimpleLogger    = simpleLogger;
     _DetailedLogging = logConfiguration.DetailedLogging;
     _MethodNamesFromStackFramesExtractor = methodNamesFromStackFramesExtractor;
 }
コード例 #2
0
 /// <summary>
 /// Instantiates a synchronous logging object.
 /// </summary>
 /// <param name="logConfiguration">Log configuration object should be provided.</param>
 /// <param name="consoleAvailable">If console is available, and we want to log on console as well it should be set to true.</param>
 public LogUtility(ILogConfiguration logConfiguration, bool consoleAvailable = false)
 {
     _configuration = logConfiguration;
     ConsoleWriter  = consoleAvailable ? (IConsoleWriter)(new ConsoleWriter(_configuration.LoggerLevel)): new NullConsoleWriter();
     CreateLogger();
     LoggerStartupInformation = new SystemInformation(this);
 }
コード例 #3
0
        /// <summary>
        /// Initialize Logs API.
        /// </summary>
        /// <param name="logFactory">Log factory.</param>
        /// <param name="configuration">Log configuration.</param>
        /// <param name="logManager">Logs manager.</param>
        public static void Init(ILogFactory logFactory, ILogConfiguration configuration, ILogManager logManager)
        {
            if (Logs.logFactory != null)
            {
                throw new InvalidOperationException($"Cannot initialize Logs API: {nameof(Logs.logFactory)} has already been initialized");
            }
            if (Logs.configuration != null)
            {
                throw new InvalidOperationException($"Cannot initialize Logs API: {nameof(Logs.configuration)} has already been initialized");
            }
            if (Logs.logManager != null)
            {
                throw new InvalidOperationException($"Cannot initialize Logs API: {nameof(Logs.logManager)} has already been initialized");
            }

            if (logFactory == null)
            {
                throw new ArgumentNullException(nameof(logFactory));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (logManager == null)
            {
                throw new ArgumentNullException(nameof(logManager));
            }

            Logs.logFactory    = logFactory;
            Logs.configuration = configuration;
            Logs.logManager    = logManager;
        }
コード例 #4
0
ファイル: LogManager.cs プロジェクト: gmeller/log-exercise
        private static void ProcessLog(LogType type, string message, ILogConfiguration logConfiguration)
        {
            foreach (var logger in logConfiguration.Loggers)
            {
                switch (type)
                {
                case LogType.Message:
                    if (logConfiguration.LogMessage)
                    {
                        logger.LogMessage(message);
                    }
                    break;

                case LogType.Warning:
                    if (logConfiguration.LogWarning)
                    {
                        logger.LogWarning(message);
                    }
                    break;

                case LogType.Error:
                    if (logConfiguration.LogError)
                    {
                        logger.LogError(message);
                    }
                    break;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SyncProcessingPipelineStage"/> class.
        /// </summary>
        protected ProcessingPipelineStage()
        {
            ILogConfiguration configuration = null;

            if (sNameOfPipelineStageToCreate.Value.Count > 0)
            {
                var constructionData = sNameOfPipelineStageToCreate.Value.Peek();
                Name          = constructionData.Name;
                configuration = constructionData.Configuration;
            }
            else
            {
                Name = $"Unnamed ({Guid.NewGuid():D})";
            }

            lock (mSettingProxies)             // ensures that a configuration change does not disturb the setup
            {
                // set the log configuration
                mConfiguration = configuration ?? new VolatileLogConfiguration();
                mConfiguration.RegisterChangedEventHandler(OnLogConfigurationChanged, false);

                // get the settings associated with the pipeline stage to create
                mSettings =
                    mConfiguration.ProcessingPipeline.Stages.FirstOrDefault(x => x.Name == Name) ??
                    mConfiguration.ProcessingPipeline.Stages.AddNew(Name);

                // setting proxies do not need to be rebound as there are no proxies, yet
                Debug.Assert(mSettingProxies.Count == 0);
            }
        }
コード例 #6
0
        public ExtensibleLogger(ILogConfiguration configuration, bool escapeLineBreaks)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            this.configuration    = configuration;
            this.escapeLineBreaks = escapeLineBreaks;
            try
            {
                this.buildNumber = ExchangeSetupContext.InstalledVersion.ToString();
            }
            catch (SetupVersionInformationCorruptException)
            {
                this.buildNumber = string.Empty;
            }
            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            this.logSchema = new LogSchema("Microsoft Exchange Server", version, this.configuration.LogType, ExtensibleLogger.Fields);
            this.log       = new Log(this.configuration.LogPrefix, new LogHeaderFormatter(this.logSchema), this.configuration.LogComponent);
            this.log.Configure(this.configuration.LogPath, this.configuration.MaxLogAge, this.configuration.MaxLogDirectorySizeInBytes, this.configuration.MaxLogFileSizeInBytes);
            if (this.configuration.IsActivityEventHandler)
            {
                ActivityContext.OnActivityEvent += this.OnActivityContextEvent;
            }
            ActivityContext.RegisterMetadata(typeof(ExtensibleLoggerMetadata));
        }
コード例 #7
0
ファイル: LogReader.cs プロジェクト: peschuster/LogImporter
        public LogReader(ILogConfiguration adapter)
        {
            if (adapter == null)
                throw new ArgumentNullException("adapter");

            this.adapter = adapter;
        }
コード例 #8
0
        /// <summary>
        /// Instantiates an asynchronous logging object.
        /// </summary>
        /// <param name="logConfiguration">Log configuration object should be provided.</param>
        /// <param name="consoleAvailable">If console is available, and we want to log on console as well it should be set to true.</param>
        public AsynchronousLogUtility(ILogConfiguration logConfiguration, bool consoleAvailable = false)
            : base(logConfiguration, consoleAvailable)
        {
            BeginStartupInformationLog();
            var writer = new Thread(WriteMessageToFile);

            writer.Start();
        }
コード例 #9
0
ファイル: RobotAssembler.cs プロジェクト: anurse/NuBot
        public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<ComposablePartCatalog> partCatalogs)
        {
            _configuration = configuration;
            _logConfiguiration = logConfiguration;
            _log = _logConfiguiration.CreateLogger("RobotAssembler");

            Compose(partCatalogs);
        }
コード例 #10
0
 public Logger()
 {
     //_configuration = new DbLogConfiguration(
     //    "DefaultConnection",
     //    new DefaultMessageSerializer(),
     //    new LogDbDataAccess("DefaultConnection"));
     _configuration     = new DefaultLogConfiguration();
     _messageSerializer = _configuration.Serializer;
 }
コード例 #11
0
 public LogController(ILogConfiguration logConfiguration, string applicationName)
 {
     if (logConfiguration.Log)
     {
         var logFile = new LogFileUserInterface(logConfiguration.LogFilePath, applicationName,
                                                logConfiguration.LogDetail, logConfiguration.LogsPerFile);
         _uis.Add(logFile);
     }
 }
コード例 #12
0
 public CacheckApplication(IButtonNameToCommandMapper buttonNameToCommandMapper, IToggleButtonNameToHandlerMapper toggleButtonNameToHandlerMapper,
                           IGuiAndApplicationSynchronizer <ICacheckApplicationModel> guiAndApplicationSynchronizer, ICacheckApplicationModel model,
                           ITashAccessor tashAccessor, ISimpleLogger simpleLogger, ILogConfiguration logConfiguration
                           ) : base(buttonNameToCommandMapper, toggleButtonNameToHandlerMapper, guiAndApplicationSynchronizer, model)
 {
     TashAccessor     = tashAccessor;
     SimpleLogger     = simpleLogger;
     LogConfiguration = logConfiguration;
 }
コード例 #13
0
 public LogController(ILogConfiguration logConfiguration)
 {
     if (logConfiguration.Log)
     {
         var logFile = new LogFileUserInterface(logConfiguration.LogFilePath, logConfiguration.LogFilePrefix,
             logConfiguration.LogDetail);
         _uis.Add(logFile);
     }
 }
コード例 #14
0
ファイル: Logger.cs プロジェクト: unchase/ViennaNET
        /// <summary>
        ///   re-configure logger by specifing logger factory configurarion
        /// </summary>
        /// <param name="configuration">log configuration factory object</param>
        public static void Configure(ILogConfiguration configuration)
        {
            var newLoggerImpl = configuration.BuildLogger();

            if (newLoggerImpl != null)
            {
                Interlocked.Exchange(ref loggerImpl, newLoggerImpl);
            }
        }
コード例 #15
0
 public ILoggerSyntax Configuration(ILogConfiguration config)
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     _config = config;
     return(this);
 }
コード例 #16
0
 public LogController(ILogConfiguration logConfiguration)
 {
     if (logConfiguration.Log)
     {
         var logFile = new LogFileUserInterface(logConfiguration.LogFilePath, logConfiguration.LogFilePrefix,
             logConfiguration.LogDetail);
         _uis.Add(logFile);
     }
 }
コード例 #17
0
    public TashAccessorTest()
    {
        var builder   = new ContainerBuilder().UseDvinAndPegh("TashClient", new DummyCsArgumentPrompter());
        var container = builder.Build();

        _DvinRepository   = container.Resolve <IDvinRepository>();
        _SimpleLogger     = container.Resolve <ISimpleLogger>();
        _LogConfiguration = container.Resolve <ILogConfiguration>();
        _MethodNamesFromStackFramesExtractor = new MethodNamesFromStackFramesExtractor();
    }
コード例 #18
0
        private static string GetLogDirectory(IHostingEnvironment env, ILogConfiguration nLogConfig)
        {
            var environment = GetEnvironmentName(env);

            string logDirectory = environment.Equals("Local", StringComparison.InvariantCultureIgnoreCase)
                            ? nLogConfig.LogDirectoryLocal
                            : nLogConfig.LogDirectory;

            return(logDirectory);
        }
コード例 #19
0
        private static void SetConfiguration(ILogConfiguration configuration)
        {
            lock (LockObject)
            {
                _ignoreDebug = configuration.IgnoreDebug;

                if (configuration.WriterConfigurationList.Count > 0)
                {
                    foreach (var writerConfig in configuration.WriterConfigurationList)
                    {
                        Assembly assembly = null;
                        try
                        {
                            assembly = string.IsNullOrEmpty(writerConfig.LoadDll) ? Assembly.GetExecutingAssembly() : Assembly.LoadFrom(writerConfig.LoadDll);

                            var types = assembly.GetClassTypes(typeof(ILogWriter));

                            var typeToInstantiate = types.SingleOrDefault(t => t.Name == writerConfig.LogWriterType);
                            if (typeToInstantiate == null)
                            {
                                throw (new Exception(
                                           $"No writers of the name '{writerConfig.LogWriterType}' were found in the assembly '{assembly.FullName}'"));
                            }

                            var lw = (ILogWriter)assembly.CreateInstance(typeToInstantiate.FullName);
                            if (lw != null)
                            {
                                lw.Initialize(writerConfig);

                                AddWriter(lw);
                            }
                        }
                        catch (ReflectionTypeLoadException rtle)
                        {
                            WriteSystem($"An error occurred attempting to load LogWriter '{writerConfig.LogWriterType}' from Assembly \"{(assembly == null ? "Not Found" : assembly.FullName)}\"");
                            foreach (var loaderException in rtle.LoaderExceptions)
                            {
                                WriteSystem($"LoaderException 'loaderException.ToString()':");
                            }
                            throw;
                        }
                        catch (Exception)
                        {
                            WriteSystem($"An error occurred attempting to load LogWriter '{writerConfig.LogWriterType}' from Assembly \"{(assembly == null ? "Not Found" : assembly.FullName)}\"");
                            throw;
                        }
                    }
                }

                RegisterAppDomainForUnhandledException(AppDomain.CurrentDomain);
                WriteTrace($"Logging Initialized [Configuration.IsLoggerDebug: {_ignoreDebug}]", typeof(Log).FullName, MethodBase.GetCurrentMethod().Name);
                PurgeAllWriters();
            }
        }
コード例 #20
0
        static Log()
        {
            ILogConfiguration configuration = LogConfigurationSection.Get();

            if (configuration == null)
            {
                return;
            }

            SetConfiguration(configuration);
        }
コード例 #21
0
ファイル: Robot.cs プロジェクト: anurse/NuBot
        public Robot(string name, ILogConfiguration logConfig, IRobotConfiguration configuration, IMessageBus bus, IEnumerable<IPart> parts, IHttpHost httpHost)
        {
            var loggerName = String.Format("Robot.{0}", name);
            _logger = logConfig.CreateLogger(loggerName);

            Name = name;
            Configuration = configuration;
            Parts = parts;
            HttpHost = httpHost;
            Bus = bus;
        }
コード例 #22
0
        public PerfLoop(ILog log, ILogConfiguration configuration)
        {
            this.log       = log ?? throw new ArgumentNullException(nameof(log));
            _configuration = configuration;

            var thread = new Thread(Loop)
            {
                IsBackground = true
            };

            thread.Start();
        }
コード例 #23
0
ファイル: MessageLog.cs プロジェクト: garora/EmailUtility
 private MessageLog(ILogConfiguration logConfiguration)
 {
     mLogConfiguration = logConfiguration;
     try
     {
         InitializeConfigFile();
     }
     catch (Exception ex)
     {
         LogLogFailure(ex.ToString());
     }
 }
コード例 #24
0
        static BaseBindings()
        {
            SettingsReader   = new SettingsLibReader();
            _DbFactory       = new MsSqlFactory(SettingsReader.GetDbAccessSettings());
            _CooksManager    = new CookieMananger();
            _UsrStateManager = new UserAuthenticateStateManager(_DbFactory, _CooksManager);

            _LogConfiguration = new BasicNLogConfig(SettingsReader.GetLogDirectory());
            _LogConfiguration.InitConfig();

            _Lg = LogManager.GetCurrentClassLogger();
            _Lg.Info("Basic bindings initialized successguly.");
        }
コード例 #25
0
ファイル: Logger.cs プロジェクト: NagababuCGvak/B4YMLive
 public Logger(ILogConfiguration configuration, ILogRepository logRepository)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (logRepository == null)
     {
         throw new ArgumentNullException("logRepository");
     }
     _configuration     = configuration;
     _logRepository     = logRepository;
     _messageSerializer = configuration.Serializer;
 }
コード例 #26
0
 /// <summary>
 /// Creates a new pipeline stage with the specified name and settings.
 /// </summary>
 /// <typeparam name="TPipelineStage">Type of the pipeline stage to create.</typeparam>
 /// <param name="name">Name of the pipeline stage to create.</param>
 /// <param name="configuration">The logging configuration (<c>null</c> to set up a volatile configuration with defaults).</param>
 /// <returns>The created pipeline stage.</returns>
 public static TPipelineStage Create <TPipelineStage>(
     string name,
     ILogConfiguration configuration)
     where TPipelineStage : ProcessingPipelineStage, new()
 {
     try
     {
         var constructionData = new ConstructionData {
             Name = name, Configuration = configuration
         };
         sNameOfPipelineStageToCreate.Value.Push(constructionData);
         return(new TPipelineStage());
     }
     finally
     {
         sNameOfPipelineStageToCreate.Value.Pop();
     }
 }
コード例 #27
0
        private static NLogConfiguration CustomNLogConfiguration(ILogConfiguration logConfiguration, IHostingEnvironment env)
        {
            var logDirectory = string.IsNullOrEmpty(logConfiguration.LogDirectory)
                            ? "../logs"
                            : logConfiguration.LogDirectory;

            var logDirectoryLocal = string.IsNullOrEmpty(logConfiguration.LogDirectoryLocal)
                            ? logDirectory
                            : logConfiguration.LogDirectoryLocal;

            var envAppName = GetAppName(env);

            return(new NLogConfiguration
            {
                EnableWebLogs = logConfiguration.EnableWebLogs,
                EnableAllLogs = logConfiguration.EnableAllLogs,
                LogDirectory = logDirectory,
                LogDirectoryLocal = logDirectoryLocal,
                AppName = string.IsNullOrEmpty(logConfiguration.AppName) ? envAppName : logConfiguration.AppName
            });
        }
コード例 #28
0
        public TextAdventureGame(
            GraphicsDevice graphicsDevice,
            Engine.Objects.World world,
            Player player,
            IMultimediaPlayer multimediaPlayer,
            IFpsConfiguration fpsConfiguration,
            ILogConfiguration logConfiguration,
            IWorldTimeConfiguration worldTimeConfiguration)
            : base(graphicsDevice, new ContentDirectoryContentManagerProvider())
        {
            world.ThrowIfNull("world");
            player.ThrowIfNull("player");
            multimediaPlayer.ThrowIfNull("multimediaPlayer");
            fpsConfiguration.ThrowIfNull("fpsConfiguration");
            logConfiguration.ThrowIfNull("logConfiguration");
            worldTimeConfiguration.ThrowIfNull("worldTimeConfiguration");

            _world                  = world;
            _player                 = player;
            _multimediaPlayer       = multimediaPlayer;
            _fpsConfiguration       = fpsConfiguration;
            _logConfiguration       = logConfiguration;
            _worldTimeConfiguration = worldTimeConfiguration;
        }
コード例 #29
0
ファイル: LogManager.cs プロジェクト: gmeller/log-exercise
        /// <summary>
        /// Logs into loggers the message provided.
        /// </summary>
        /// <param name="type">Type of message (error, warning or message).</param>
        /// <param name="message">Message to log.</param>
        /// <param name="logConfiguration">Configuration to get loggers and log types to log.</param>
        public static void Log(LogType type, string message, ILogConfiguration logConfiguration = null)
        {
            //TODO: Make a cache for configuration
            //Gets configuration in the case that user doesnt provide it
            if (logConfiguration == null)
            {
                logConfiguration = new LogConfiguration();
            }

            //If there are no loggers
            if (logConfiguration.Loggers.Count() == 0)
            {
                throw new System.Exception("Invalid Configuration");
            }

            //If there is nothing configured to be logged
            if (!logConfiguration.LogError && !logConfiguration.LogMessage && !logConfiguration.LogError)
            {
                throw new System.Exception("Error or Warning or Message must be specified");
            }

            //Process the log
            ProcessLog(type, message, logConfiguration);
        }
コード例 #30
0
        public TextAdventureGame(
            GraphicsDevice graphicsDevice,
            Engine.Objects.World world,
            Player player,
            IMultimediaPlayer multimediaPlayer,
            IFpsConfiguration fpsConfiguration,
            ILogConfiguration logConfiguration,
            IWorldTimeConfiguration worldTimeConfiguration)
            : base(graphicsDevice, new ContentDirectoryContentManagerProvider())
        {
            world.ThrowIfNull("world");
            player.ThrowIfNull("player");
            multimediaPlayer.ThrowIfNull("multimediaPlayer");
            fpsConfiguration.ThrowIfNull("fpsConfiguration");
            logConfiguration.ThrowIfNull("logConfiguration");
            worldTimeConfiguration.ThrowIfNull("worldTimeConfiguration");

            _world = world;
            _player = player;
            _multimediaPlayer = multimediaPlayer;
            _fpsConfiguration = fpsConfiguration;
            _logConfiguration = logConfiguration;
            _worldTimeConfiguration = worldTimeConfiguration;
        }
コード例 #31
0
 public static ILoggerProvider CreateNetCoreLoggerProvider(this ILogConfiguration config)
 {
     return(new LogMagicLoggerProvider());
 }
コード例 #32
0
ファイル: RobotAssembler.cs プロジェクト: anurse/NuBot
 public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<string> partDirectories)
     : this(configuration, logConfiguration, Enumerable.Empty<Assembly>(), partDirectories)
 {
 }
コード例 #33
0
 protected LogProviderBase(ILogConfiguration config)
 {
     _config = config;
 }
コード例 #34
0
ファイル: Logger.cs プロジェクト: Scubaboy/QuadWebAppComms
 public TheLogger(ILogConfiguration logConfiguration)
 {
     logConfiguration.Configure();
 }
コード例 #35
0
ファイル: MessageLog.cs プロジェクト: garora/EmailUtility
 public static void InitializeLog(ILogConfiguration logConfiguration)
 {
     try
     {
         if (mInstance != null)
             DisposeInstance();
         mInstance = new MessageLog(logConfiguration);
     }
     catch (Exception ex)
     {
         LogLogFailure("public static void InitializeLog(ILogConfiguration " +
                       logConfiguration.GetType().FullName + ")" + Environment.NewLine + ex);
     }
 }
コード例 #36
0
ファイル: RobotAssembler.cs プロジェクト: anurse/NuBot
 public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<Assembly> partAssemblies, IEnumerable<string> partDirectories)
     : this(configuration, logConfiguration, BuildCatalogs(partAssemblies, partDirectories))
 {
 }
コード例 #37
0
 public static void SetLogConfiguration(ILogConfiguration config)
 {
     Instance.logConfiguration = config;
 }
コード例 #38
0
 private JobLogger()
 {
     logConfiguration = Locator.Resolve <ILogConfiguration>() ?? new DefaultLogConfiguration();
     logSourceFactory = Locator.Resolve <ILogSourceFactory>() ?? new LogSourceFactory();
 }
コード例 #39
0
ファイル: RobotAssembler.cs プロジェクト: anurse/NuBot
 public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration)
     : this(configuration, logConfiguration, Enumerable.Empty<Assembly>(), Enumerable.Empty<string>())
 {
 }
コード例 #40
0
 public LogConfiguration(string applicationName)
 {
     LogSubFolder = @"AspenlaubLogs\" + applicationName;
     Instance     = this;
 }
コード例 #41
0
ファイル: RobotAssembler.cs プロジェクト: anurse/NuBot
 public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<Assembly> partAssemblies)
     : this(configuration, logConfiguration, partAssemblies, Enumerable.Empty<string>())
 {
 }