public TashAccessor(IDvinRepository dvinRepository, ISimpleLogger simpleLogger, ILogConfiguration logConfiguration, IMethodNamesFromStackFramesExtractor methodNamesFromStackFramesExtractor) { DvinRepository = dvinRepository; _SimpleLogger = simpleLogger; _DetailedLogging = logConfiguration.DetailedLogging; _MethodNamesFromStackFramesExtractor = methodNamesFromStackFramesExtractor; }
/// <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); }
/// <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; }
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; } } }
/// <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); } }
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)); }
public LogReader(ILogConfiguration adapter) { if (adapter == null) throw new ArgumentNullException("adapter"); this.adapter = adapter; }
/// <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(); }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<ComposablePartCatalog> partCatalogs) { _configuration = configuration; _logConfiguiration = logConfiguration; _log = _logConfiguiration.CreateLogger("RobotAssembler"); Compose(partCatalogs); }
public Logger() { //_configuration = new DbLogConfiguration( // "DefaultConnection", // new DefaultMessageSerializer(), // new LogDbDataAccess("DefaultConnection")); _configuration = new DefaultLogConfiguration(); _messageSerializer = _configuration.Serializer; }
public LogController(ILogConfiguration logConfiguration, string applicationName) { if (logConfiguration.Log) { var logFile = new LogFileUserInterface(logConfiguration.LogFilePath, applicationName, logConfiguration.LogDetail, logConfiguration.LogsPerFile); _uis.Add(logFile); } }
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; }
public LogController(ILogConfiguration logConfiguration) { if (logConfiguration.Log) { var logFile = new LogFileUserInterface(logConfiguration.LogFilePath, logConfiguration.LogFilePrefix, logConfiguration.LogDetail); _uis.Add(logFile); } }
/// <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); } }
public ILoggerSyntax Configuration(ILogConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } _config = config; return(this); }
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(); }
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); }
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(); } }
static Log() { ILogConfiguration configuration = LogConfigurationSection.Get(); if (configuration == null) { return; } SetConfiguration(configuration); }
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; }
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(); }
private MessageLog(ILogConfiguration logConfiguration) { mLogConfiguration = logConfiguration; try { InitializeConfigFile(); } catch (Exception ex) { LogLogFailure(ex.ToString()); } }
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."); }
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; }
/// <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(); } }
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 }); }
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; }
/// <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); }
public static ILoggerProvider CreateNetCoreLoggerProvider(this ILogConfiguration config) { return(new LogMagicLoggerProvider()); }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<string> partDirectories) : this(configuration, logConfiguration, Enumerable.Empty<Assembly>(), partDirectories) { }
protected LogProviderBase(ILogConfiguration config) { _config = config; }
public TheLogger(ILogConfiguration logConfiguration) { logConfiguration.Configure(); }
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); } }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<Assembly> partAssemblies, IEnumerable<string> partDirectories) : this(configuration, logConfiguration, BuildCatalogs(partAssemblies, partDirectories)) { }
public static void SetLogConfiguration(ILogConfiguration config) { Instance.logConfiguration = config; }
private JobLogger() { logConfiguration = Locator.Resolve <ILogConfiguration>() ?? new DefaultLogConfiguration(); logSourceFactory = Locator.Resolve <ILogSourceFactory>() ?? new LogSourceFactory(); }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration) : this(configuration, logConfiguration, Enumerable.Empty<Assembly>(), Enumerable.Empty<string>()) { }
public LogConfiguration(string applicationName) { LogSubFolder = @"AspenlaubLogs\" + applicationName; Instance = this; }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<Assembly> partAssemblies) : this(configuration, logConfiguration, partAssemblies, Enumerable.Empty<string>()) { }