Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <StaticLoggerHelper> logger, IApiVersionDescriptionProvider provider)
        {
            logger.Initialize();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    //c.SwaggerEndpoint("/swagger/v1/swagger.json", "APIFramework.API v1");
                    // build a swagger endpoint for each discovered API version
                    foreach (var description in provider.ApiVersionDescriptions)
                    {
                        c.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", $"APIFramework - {description.GroupName.ToUpperInvariant()}");
                    }
                });
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Exemple #2
0
 static FifoLogger()
 {
     LogQueue = new Queue<Log>();
     LockObject = new object();
     ActualLogger = UnityConfig.Instance.Container.Resolve<Log4NetLogger>();
     ActualLogger.Initialize(typeof(FifoLogger));
 }
Exemple #3
0
        static void Main()
        {
            UnityConfig.Instance.Configure();
            LogConfig.Instance.LogFile = "hcs.log";
            LogConfig.Instance.Configure();

            FifoLogger.StartWorking();

            Log = new FifoLogger();
            Log.Initialize(typeof(Program));
            
            var deviceConfigurationFile = ApplicationSettings.GetString("DeviceSettingsFile");
            var configurationReader = new HcsDeviceConfigurationReader(deviceConfigurationFile);
            configurationReader.Initialize();
            DeviceConfigurationRegistry.Instance.Register(configurationReader);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            if (ReadAuthenticationSettings())
            {
                ShowLoginDialog();
            }

            var deviceLifetimeManager = UnityConfig.Instance.Container.Resolve<DeviceLifetimeManager>();
            deviceLifetimeManager.Dispose();
            FifoLogger.StopWorking();
        }
Exemple #4
0
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    if (_cache == null)
                    {
                        LegacyProvider.s_onAppDomainUnload = new EventHandler(OnAppDomainUnload);
                        System.Threading.Thread.GetDomain().DomainUnload += LegacyProvider.s_onAppDomainUnload;

                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, _cacheId);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                    {
                                        NCacheLog.SetLevel("info");
                                    }
                                }
                            }
                        }
                        if (_isLocationAffinityEnabled)
                        {
                            _cache = new RegionalCache(_ncacheLog, NCacheSessionStateConfigReader.LoadSessionLocationSettings());
                        }
                        else
                        {
                            _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);
                        }

                        _cache.InitializeCache(_cacheId);
                        _cache.ExceptionsEnabled = true;
                        s_cacheNeedInit          = false;
                        if (_logs)
                        {
                            NCacheLog.Info("NSessionStoreProvider initialized");
                        }
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; // so that next time cache can be initialized. Check the above condition if(_cache == null)
                    RaiseException(exc);
                }
            }
        }
 public void Setup()
 {
     _logger = new Logger();
     _logger.Initialize();
     _items = new List<string>();
     _running = true;
     var logger = _logger.Appenders.First(x => x.GetType() == typeof (FileLoggerAppender));
     logger.OnLogWritten += OnLogWritten;
 }
Exemple #6
0
        /// <summary>
        /// Attach the specified <see cref="ILogger"/> to this instance.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <exception cref="ArgumentNullException"><paramref name="logger" /> is <c>null</c>.</exception>
        public void Initialize(ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            logger.Initialize(this.EventSource);
        }
Exemple #7
0
        public void RegisterLogger(ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            logger.Initialize(eventSource);
            loggers.Add(logger);
        }
Exemple #8
0
        public void EnableLogging()
        {
            _loggerInfo = new TopicLogger();
            _loggerInfo.Initialize("RPCServer.info");
            _loggerInfo.SetSilent(true);

            _loggerError = new TopicLogger();
            _loggerError.Initialize("RPCServer.Error");
            _loggerError.SetSilent(true);
        }
 public static ILogger GetLogger(string configName = null)
 {
     if (string.IsNullOrWhiteSpace(configName))
     {
         configName = LoggerConfig;
         if (string.IsNullOrWhiteSpace(configName))
         {
             if (_profiles != null && _profiles.Count > 0)
             {
                 foreach (LoggerProfileSettings profile in _profiles)
                 {
                     if (profile.Default)
                     {
                         configName = profile.Name;
                         break;
                     }
                 }
             }
         }
         if (string.IsNullOrWhiteSpace(configName))
         {
             //throw new ArgumentNullException("configName");
             return(_dummyLogger);
         }
     }
     if (_profiles != null && _profiles.Count > 0)
     {
         var profile = _profiles[configName];
         if (profile != null)
         {
             string loggerName = profile.Logger;
             if (string.IsNullOrWhiteSpace(loggerName))
             {
                 loggerName = BATCH_DEFAULT_LOGGER;
             }
             if (profile.Enable)
             {
                 ILogger Logger = profile.Container.GetExportedValueOrDefault <ILogger>(loggerName);
                 if (Logger != null)
                 {
                     if (!Logger.IsInitialized)
                     {
                         Logger.Initialize(profile);
                     }
                     return(Logger);
                 }
             }
             else
             {
                 return(_dummyLogger);
             }
         }
     }
     return(_dummyLogger);
 }
Exemple #10
0
        public ILogger GetLogger(string scopeName)
        {
            if (!_loggers.ContainsKey(scopeName))
            {
                ILogger logger = ServiceLocator.Current.GetInstance <ILogger>();
                logger.Initialize(scopeName);
                _loggers.Add(scopeName, logger);
            }

            return(_loggers[scopeName]);
        }
Exemple #11
0
 void OnTaskStarted(object sender, TaskStartedEventArgs e)
 {
     if (desc.taskname.Equals(e.TaskName, StringComparison.OrdinalIgnoreCase))
     {
         CreateBaseLogger();
         if (baseLogger != null)
         {
             baseLogger.Initialize(eventSource);
             isActive = true;
         }
     }
 }
Exemple #12
0
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    //if (StaticLogs.IsWriterNull && _logs) StaticLogs.Initialize(_cacheId, "SessionStoreProvider");

                    if (_cache == null)
                    {
                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                string logFileNmae = _cacheId;

                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, logFileNmae);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                    {
                                        NCacheLog.SetLevel("info");
                                    }
                                }
                            }
                        }

                        _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);

                        _cache.InitializeCache(_cacheId);
                        s_cacheNeedInit = false;
                        OnCacheInitialize();
                        if (_logs)
                        {
                            LogInfo("NSessionStoreProvider initialized", null);
                        }
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; //taimoor: so that next time cache can be initialized. Check the above condition if(_cache == null)
                    LogError(exc, null);
                }
            }
        }
        public NCacheDistributedCache(IOptions <NCacheConfiguration> options)
        {
            _options = options;

            if (string.IsNullOrEmpty(options.Value.CacheName))
            {
                throw new Runtime.Exceptions.ConfigurationException("A valid Cache ID has not been specified.");
            }

            _cacheName = _options.Value.CacheName;

            if ((options.Value.EnableLogs != null && options.Value.EnableLogs.Value) ||
                (options.Value.EnableDetailLogs != null && options.Value.EnableDetailLogs.Value))
            {
                try
                {
                    _logger = new NCacheLogger();
                    _logger.Initialize(LoggerNames.SessionStoreProvider, options.Value.CacheName);

                    if (options.Value.EnableDetailLogs != null && options.Value.EnableDetailLogs.Value)
                    {
                        _logger.SetLevel("all");
                    }
                    else
                    {
                        _logger.SetLevel("info");
                    }
                }
                catch (Exception ex)
                {
                    LogError(ex);
                }
            }

            if (options.Value.WriteExceptionsToEventLog != null && options.Value.WriteExceptionsToEventLog.Value)
            {
                _writeExceptionsToEventLog = true;
            }

            if (options.Value.ExceptionsEnabled != null && options.Value.ExceptionsEnabled.Value)
            {
                _exceptionsEnabled = true;
            }

            CheckAndInitializeCache();
        }
Exemple #14
0
        /// <summary>
        /// Initialize log services, preferably before you start creating log objects. Optionally, you can
        /// indicate how you want to create loggers.
        /// </summary>
        public static void Initialize(Func <DIFactory, ILogger> creator = null, bool recreateDefaultLogger = true)
        {
            if (creator != null)
            {
                if (!LogCreator.CreationMapping.ContainsKey(typeof(ILogger)))
                {
                    LogCreator.CreationMapping.Add(typeof(ILogger), creator);
                }
                else
                {
                    LogCreator.CreationMapping[typeof(ILogger)] = creator;
                }
            }

            if (recreateDefaultLogger || DefaultLogger == null)
            {
                DefaultLogger = LogCreator.Create <ILogger>();
                DefaultLogger.Initialize("DefaultLogger");
            }
        }
Exemple #15
0
        /// <summary>
        /// Starts the main application.
        /// </summary>
        /// <returns>An infinite task.</returns>
        private async Task MainAsync()
        {
            _logger = new SerilogLogger();
            _logger.Initialize();

            _discordClient  = new DiscordSocketClient();
            _commandService = new CommandService();

            _discordClient.Log += Log;

            var commandHandler = new CommandHandler(_discordClient, _commandService);
            await commandHandler.InstallCommandsAsync(BuildServiceProvider());

            var token = Environment.GetEnvironmentVariable("DiscordToken");
            await _discordClient.LoginAsync(TokenType.Bot, token);

            await _discordClient.StartAsync();

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
Exemple #16
0
        private static void PlaybackBinlog(string binlogFilePath, params ILogger[] loggers)
        {
            var replayEventSource = new BinaryLogReplayEventSource();

            foreach (var logger in loggers)
            {
                if (logger is INodeLogger nodeLogger)
                {
                    nodeLogger.Initialize(replayEventSource, 1);
                }
                else
                {
                    logger.Initialize(replayEventSource);
                }
            }

            replayEventSource.Replay(binlogFilePath);

            foreach (var logger in loggers)
            {
                logger.Shutdown();
            }
        }
Exemple #17
0
        public App(
            Emulator emulator,
            ILogger logger,
            CommandSender commandSender,
            IInputReader input
            )
        {
            _commandChannel = Channel.CreateUnbounded <string>();
            _logChannel     = Channel.CreateUnbounded <string>();
            _inputChannel   = Channel.CreateUnbounded <string>();

            _emulator      = emulator;
            _logger        = logger;
            _input         = input;
            _commandSender = commandSender;

            _emulator.Initialize(_commandChannel.Reader, _logChannel.Writer);
            _input.Initialize(_inputChannel.Writer);
            _logger.Initialize(_logChannel.Reader);
            _commandSender.Initialize(
                _inputChannel.Reader,
                _commandChannel.Writer,
                _logChannel.Writer);
        }
Exemple #18
0
        /// <summary>
        /// Attach the specified <see cref="ILogger"/> to this instance.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <exception cref="ArgumentNullException"><paramref name="logger" /> is <c>null</c>.</exception>
        public void Initialize(ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            logger.Initialize(this.EventSource);
        }
Exemple #19
0
 /// <summary>
 /// Initialize the logger
 /// </summary>
 internal void InitializeLogger(List<ILogger> loggerList, ILogger logger, IEventSource sourceForLogger)
 {
     // Node loggers are central /l loggers which can understand how many CPU's the build is running with, they are only different in that
     // they can take a number of CPU
     INodeLogger nodeLogger = logger as INodeLogger;
     if (null != nodeLogger)
     {
         nodeLogger.Initialize(sourceForLogger, 1);
     }
     else
     {
         logger.Initialize(sourceForLogger);
     }
 }
Exemple #20
0
        private void InitializeCache(HttpApplication application)
        {
            this._cacheId = ConfigurationSettings.AppSettings["cacheName"];
            if (this._cacheId == null || this._cacheId == string.Empty)
            {
                throw new ConfigurationException("The 'cacheName' attribute cannot be null or empty string");
            }

            string[] boolValStrings = { "exceptionsEnabled", "writeExceptionsToEventLog",
                                        "enableLogs",        "enableDetailLogs", "clearASPSession" };
            string   configVal = null;
            bool     value     = false;

            for (int i = 0; i < boolValStrings.Length; i++)
            {
                configVal = ConfigurationSettings.AppSettings[boolValStrings[i]];
                if (configVal != null)
                {
                    if (configVal != "true" && configVal != "false")
                    {
                        throw new ConfigurationException("The '" + boolValStrings[i] + "' attribute must be one of the following values: true, false.");
                    }
                    else
                    {
                        value = Convert.ToBoolean(configVal);
                        switch (i)
                        {
                        case 0: this._exceptionsEnabled = value; break;

                        case 1: this._writeExceptionsToEventLog = value; break;

                        case 2: this._logs = value; break;

                        case 3: this._detailedLogs = value; break;

                        case 4: this._clearASPSession = value; break;
                        }
                    }
                }
            }
            if (this._logs || this._detailedLogs)
            {
                if (_ncacheLog == null)
                {
                    _ncacheLog = new NCacheLogger();
                    _ncacheLog.Initialize(LoggerNames.HttpModule, this._cacheId);

                    if (this._detailedLogs)
                    {
                        NCacheLog.SetLevel("all");
                    }
                    else
                    {
                        if (this._logs)
                        {
                            NCacheLog.SetLevel("info");
                        }
                    }
                }
            }

            _applicationId = ConfigurationSettings.AppSettings["sessionAppId"];

            if (_isLocationAffinityEnabled)
            {
                _cache = new RegionalCache(_ncacheLog, NCacheSessionStateConfigReader.LoadSessionLocationSettings());
            }
            else
            {
                _cache = new SingleRegionCache();
            }

            try
            {
                this._cache.InitializeCache(this._cacheId);
                this._cache.ExceptionsEnabled = true;
                if (NCacheLog != null)
                {
                    NCacheLog.Info("NSessionStateModule initialized");
                }
                application.Application["NSessionStateModule.Cache"] = this._cache;
            }
            catch (Exception e)
            {
                RaiseExceptions(e);
            }
        }
Exemple #21
0
 public void Initialize(IEventSource eventSource)
 {
     _logger.Initialize(eventSource);
 }
Exemple #22
0
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="application">An <see cref="System.Web.HttpApplication"/> object that provides
        /// references to the intrinsic server objects (for example,
        /// Request, Response, Session, and Server) used to service HTTP requests.
        /// </param>
        void IHttpModule.Init(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            this._onResolveRequestCache = new EventHandler(ResolveRequestCache);
            this._onUpdaterequestCache  = new EventHandler(UpdateRequestCache);
            this._onDispose             = new EventHandler(Dispose);

            application.ResolveRequestCache += this._onResolveRequestCache;
            application.UpdateRequestCache  += this._onUpdaterequestCache;
            application.Disposed            += this._onDispose;

            if (_reader == null)
            {
                lock (s_mutex)
                {
                    if (_reader == null)
                    {
                        NItem.RegisterTypeWithCompactFramework();
                        _reader   = new OutPutCacheConfigReader();
                        _settings = _reader.LoadCacheSettings();
                        _reader.LoadPageSettings();
                    }
                }
            }

            try
            {
                if (IsNullOrEmpty(_settings.CacheName))
                {
                    return;
                }

                if (_settings.EnableLogs || _settings.EnableDetailedLogs)
                {
                    _ncacheLog = new NCacheLogger();
                    _ncacheLog.Initialize(LoggerNames.OutputCache, _settings.CacheName);

                    if (_settings.EnableDetailedLogs)
                    {
                        NCacheLog.SetLevel("all");
                    }
                    else
                    {
                        if (_settings.EnableLogs)
                        {
                            NCacheLog.SetLevel("info");
                        }
                    }
                }

                lock (s_mutex)
                {
                    this._cache = CacheContainer.GetCacheInstance(_settings);
                }

                if (NCacheLog != null)
                {
                    NCacheLog.Info("NOutputCache initialized");
                }
            }
            catch (Exception e)
            {
                RaiseException(e);
            }
        }
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    if (_cache == null)
                    {
                        NSessionStoreProvider.s_onAppDomainUnload = new EventHandler(OnAppDomainUnload);
                        System.Threading.Thread.GetDomain().DomainUnload += NSessionStoreProvider.s_onAppDomainUnload;

                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, _cacheId);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                        NCacheLog.SetLevel("info");
                                }
                            }
                        }

                        _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);
                        _cache.InitializeCache(_cacheId);
                        _cache.ExceptionsEnabled = true;
                        s_cacheNeedInit = false;
                        if(_logs) NCacheLog.Info("NSessionStoreProvider initialized");
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; // so that next time cache can be initialized. Check the above condition if(_cache == null)
                    RaiseException(exc);
                }
            }
        }
Exemple #24
0
        public void RegisterLogger(ILogger logger)
        {
            if (logger == null)
                throw new ArgumentNullException ("logger");

            logger.Initialize (eventSource);
            loggers.Add (logger);
        }
Exemple #25
0
        internal void Initialize(bool throwIfRequiredPropertiesNotFoundInDefaultConfig)
        {
            if (currentLog == null || currentLog.IsNull)
            {
                DefaultConfiguration.SetProperties(this, false);
                currentLog = CreateLogger(this.logType);
                //if (this.logType == Naizari.Logging.LogType.MSSql)
                //{
                //    EventManager.Current.EventStoreType = EventStoreTypes.MSSql.ToString();
                //}
                //else
                //{
                //    EventManager.Current.EventStoreType = EventStoreTypes.SQLite.ToString();
                //}

                currentLog.Initialize();
                DefaultConfiguration.SetPropertiesByProxy(currentLog, this, throwIfRequiredPropertiesNotFoundInDefaultConfig);
            }

            SingletonHelper.SetApplicationProvider<ILogger>(currentLog, true);
            WireNotificationEvents(currentLog);
        }
 /// <summary>
 /// Configure logger name
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="o"></param>
 /// <returns></returns>
 public static ILogger Configure(this ILogger logger, object o)
 {
     logger.Initialize(o);
     return(logger);
 }
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    if (_cache == null)
                    {
                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                string logFileNmae = _cacheId;

                                if (_isLocationAffinityEnabled && _regionalCacheSessionStateSettings.PrimaryCache != null)
                                {
                                    foreach (string prefix in _regionalCacheSessionStateSettings.PrimaryCache.Keys)
                                    {
                                        logFileNmae = _regionalCacheSessionStateSettings.PrimaryCache[prefix] as string;
                                        break;
                                    }
                                }

                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, logFileNmae);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                    {
                                        NCacheLog.SetLevel("info");
                                    }
                                }
                            }
                        }
                        if (_isLocationAffinityEnabled)
                        {
                            string sid    = string.Empty;
                            string pcache = string.Empty;

                            if (_regionalCacheSessionStateSettings.PrimaryCache != null)
                            {
                                foreach (string prefix in _regionalCacheSessionStateSettings.PrimaryCache.Keys)
                                {
                                    sid    = prefix;
                                    pcache = _regionalCacheSessionStateSettings.PrimaryCache[prefix] as string;
                                    break;
                                }
                            }

                            if (_logs)
                            {
                                LogInfo("NsessionStoreProvider.Initialize() -> primary cache and sid : " + pcache + " : " + sid, null);
                            }
                            _cache = new RegionalCache(_ncacheLog, _regionalCacheSessionStateSettings);
                        }
                        else
                        {
                            _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);
                        }

                        _cache.InitializeCache(_cacheId);
                        _cache.ExceptionsEnabled = true;
                        s_cacheNeedInit          = false;
                        OnCacheInitialize();
                        if (_logs)
                        {
                            LogInfo("NSessionStoreProvider initialized", null);
                        }
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; // so that next time cache can be initialized. Check the above condition if(_cache == null)
                    LogError(exc, null);
                }
            }
        }
Exemple #28
0
 public void EnableLogging()
 {
     _logger = new TopicLogger();
     _logger.Initialize("worker.info");
     _logger.SetSilent(true);
 }
 public void Setup()
 {
     _logger = new Logger();
     _logger.Initialize(new NLoggerConfigurationSectionXmlLoader(Configuration));
 }
Exemple #30
0
            /// <summary>
            /// Adds the specified logger to the set of loggers for this submission.
            /// </summary>
            internal void AddLogger(ILogger logger)
            {
                lock (_syncLock)
                {
                    if (_loggers.Contains(logger))
                    {
                        throw new InvalidOperationException("Cannot register the same logger twice.");
                    }

                    // Node loggers are central /l loggers which can understand how many CPU's the build is running with, they are only different in that
                    // they can take a number of CPU
                    INodeLogger nodeLogger = logger as INodeLogger;
                    if (null != nodeLogger)
                    {
                        nodeLogger.Initialize(this, _maxNodeCount);
                    }
                    else
                    {
                        logger.Initialize(this);
                    }

                    _loggers.Add(logger);
                }
            }
Exemple #31
0
 public static void Initialize()
 {
     LoggerInstane.Initialize();
 }
Exemple #32
0
        /// <summary>
        /// Initializes the logger and adds it to the list of loggers maintained by the engine.
        /// This method is not expected to be called from multiple threads
        /// </summary>
        /// <exception cref="LoggerException">A logger exception thrown by a logger when its initialize call is made</exception>
        /// <exception cref="InternalLoggerException">Any exceptions from initializing the logger which are not loggerExceptions are caught and wrapped in a InternalLoggerException</exception>
        /// <exception cref="Exception">Any exception which is a ExceptionHandling.IsCriticalException will not be wrapped</exception>
        private void InitializeLogger(ILogger logger, IEventSource sourceForLogger)
        {
            try
            {
                INodeLogger nodeLogger = logger as INodeLogger;
                if (null != nodeLogger)
                {
                    nodeLogger.Initialize(sourceForLogger, _maxCPUCount);
                }
                else
                {
                    logger.Initialize(sourceForLogger);
                }
            }
            catch (LoggerException)
            {
                throw;
            }
            catch (Exception e)
            {
                if (ExceptionHandling.IsCriticalException(e))
                {
                    throw;
                }

                InternalLoggerException.Throw(e, null, "FatalErrorWhileInitializingLogger", true, logger.GetType().Name);
            }

            // Keep track of the loggers so they can be unregistered later on
            _iloggerList.Add(logger);
        }
 /// <summary>
 /// Registers the logger.
 /// </summary>
 /// <param name="logger">The logger.</param>
 public static void RegisterLogger(ILogger logger)
 {
     logger.Initialize();
     loggers.Add(logger);
 }
Exemple #34
0
        /// <summary>
        /// Initializes the logger and adds it to the list of loggers maintained by the engine
        /// </summary>
        /// <exception cref="LoggerException">Logger indicating it failed in a controlled way</exception>
        /// <exception cref="InternalLoggerException">Logger threw arbitrary exception</exception>
        private void RegisterLoggerInternal(ILogger logger, EventSource sourceForLogger, bool forwardingLogger)
        {
            try
            {
                if (logger is INodeLogger)
                {
                    ((INodeLogger)logger).Initialize(sourceForLogger, this.numberOfCpus);
                }
                else
                {
                    logger.Initialize(sourceForLogger);
                }
            }
            // Polite logger failure
            catch (LoggerException)
            {
                throw;
            }
            catch (Exception e)
            {
                InternalLoggerException.Throw(e, null, "FatalErrorWhileInitializingLogger", false, logger.GetType().Name);
            }

            if (forwardingLogger)
            {
                if (forwardingLoggers == null)
                {
                    forwardingLoggers = new ArrayList();
                }

                forwardingLoggers.Add(logger);
            }
            else
            {
                if (loggers == null)
                {
                    loggers = new ArrayList();
                }

                loggers.Add(logger);
            }
        }