public Logger(ILoggerContainer loggerContainer, FileLoggerContainer fileLoggerContainer) { this.loggerContainer = loggerContainer ?? throw new ArgumentNullException(nameof(loggerContainer)); this.fileLoggerContainer = fileLoggerContainer ?? throw new ArgumentNullException(nameof(fileLoggerContainer)); AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException; }
public ServiceContainerSetup Initialise() { _logger?.LogInfo("Initialising Managed Extensibility Framework container"); AggregateCatalog AggregateCatalog = new AggregateCatalog( new DirectoryCatalog( Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), _uaLibrarySettings.LibraryDirectory) ) ); CompositionContainer Container = new CompositionContainer(AggregateCatalog); _logger?.LogInfo("Composing configuration file name and logger instance"); Container.ComposeExportedValue(UaContractNames.ConfigurationFileNameContract, Path.Combine( Directory.GetCurrentDirectory(), _uaLibrarySettings.ResourcesDirectory, _uaLibrarySettings.LibraryDirectory, _uaLibrarySettings.ConsumerConfigurationFile) ); Container.ComposeExportedValue(_logger); _logger?.LogInfo("Setting a service locator"); DisposableServiceLocator = new UaooiServiceLocator(Container); ServiceLocator.SetLocatorProvider(() => DisposableServiceLocator); if (shouldComposeLoggers) { _logger?.LogInfo("Composing a common logger for all components"); loggerContainer = Container.GetExportedValue <ILoggerContainer>().EnableLoggers(); } return(this); }
/// <summary> /// Create a container based on assembly name, name, and type. /// This is normally used to create the default container. /// </summary> /// <param name="assembly">name of the assembly in question.</param> /// <param name="type">type of the container</param> /// <param name="name">name of the container</param> /// <returns>created container</returns> public ILoggerContainer CreateContainer(Assembly assembly, Type type, String name) { if (assembly == null) { throw new ArgumentNullException("assembly"); } if (type == null) { type = this.v_DefaultType; } lock (this) { ILoggerContainer container = this[assembly.GetName().Name] as ILoggerContainer; { if (container == null) { try { //LogLog("Creating repository"); container = this.CreateContainer(assembly.GetName().Name, type); this.ConfigureContainer(name, container); } catch (Exception e) { //Failure. } } } return(container); } }
public ILoggerContainer CreateContainer(string name, Type type) { if (name == null) { throw new ArgumentNullException("containerName"); } if (type == null) { type = this.v_DefaultType; } lock (this) { ILoggerContainer container = base[name] as ILoggerContainer; if (container != null) { throw new LogException("Container [" + name + "] is already defined. No redefinition of Containers allowed!"); } //Create a new one. container = (ILoggerContainer)Activator.CreateInstance(type); container.Name = name; this[name] = container; //call event for creation. return(container); } }
public Log(Type callerStackBoundaryDeclaringType, ILoggerContainer container, LogInfo data) { this.v_container = container; this.v_callerStackBoundaryDeclaringType = callerStackBoundaryDeclaringType; this.v_info = data; this.v_message = v_info.Message; this.v_exception = v_info.Exception; }
public Module(ILoggerContainer primaryLoggerContainer, IDirectoryController directories, IAppDomainFactory appDomainFactory, ModuleProxyTypeDictionary proxyTypes) { this.proxyTypes = proxyTypes; this.appDomainFactory = appDomainFactory; this.primaryLoggerContainer = primaryLoggerContainer; this.directories = directories; }
public DefaultLoader(RunCommandOnCollection runCommand, ExecuteCommandOnCollection executeCommand, ExecuteBackgroundCommandOnCollection executeBackgroundCommand, ReloadCommandOnCollection reloadCommand, AssemblyResolver resolver, DefaultModuleDirectorySupervisor directorySupervisor, ILoggerContainer logger) { this.logger = logger; this.directorySupervisor = directorySupervisor; this.resolver = resolver; this.reloadCommand = reloadCommand; this.executeBackgroundCommand = executeBackgroundCommand; this.executeCommand = executeCommand; this.runCommand = runCommand; }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { (DisposableServiceLocator as IDisposable)?.Dispose(); (loggerContainer as IDisposable)?.Dispose(); } DisposableServiceLocator = null; loggerContainer = null; ServiceLocator.SetLocatorProvider(() => null); disposedValue = true; } }
/// <summary> /// Get a container by name /// </summary> /// <param name="name">the name of the container</param> /// <returns>container with desired name</returns> public ILoggerContainer GetContainer(string name) { if (name == null) { throw new ArgumentNullException("containerName"); } ILoggerContainer container = this[name] as ILoggerContainer; if (container == null) { LogException le = new LogException("Container [" + name + "]: NOT DEFINED."); //LogLog(le); //LogLog("Creating new repository"); return(CreateContainer(name, this.v_DefaultType)); } return(container); }
/// <summary> /// Configure a given container. /// </summary> /// <param name="name">name of the container</param> /// <param name="container">the container</param> private void ConfigureContainer(string name, ILoggerContainer container) { string configLocation = LogManager.ConfigLocation; try { if (Document != null) { Document.Load(configLocation); } IConfigurator configurator = container as IConfigurator; if (configurator != null && name == DefaultContainerName) { XmlNode mainNode = Document.SelectSingleNode("logger/logger.configuration"); configurator.Configure((XmlElement)mainNode); } } catch (Exception e) { Console.WriteLine(e); } }
public Log(Type callerStackBoundaryDeclaringType, ILoggerContainer container, string loggerName, Level level, object message, Exception exception, LocationInfo info) : this(callerStackBoundaryDeclaringType, container, new LogInfo(message, callerStackBoundaryDeclaringType, level, loggerName, exception, DateTime.Now, info)) { }