static Systems() { _exCookieManager = (ICookieManager)Providers.GetProvider(ProviderType.ICookieManager); _exLogSystem = (ILogSystem)Providers.GetProvider(ProviderType.ILogSystem); _exCredentialCache = (ICredentialCache)Providers.GetProvider(ProviderType.ICredentialCache); _exUAC = (IUAC)Providers.GetProvider(ProviderType.IUAC); }
/// <summary> /// Loads a package info from this file's content if possible /// </summary> /// <param name="logger">A logging interface to write parser errors to</param> /// <param name="result">The resulting package info if processing succeeded</param> /// <returns>True if the file has successfully been processed, false otherwise</returns> public static bool GetPackage(this FileDescriptor file, ILogSystem logger, out PackageMeta result) { try { JsonDocument document = new JsonDocument(); using (Stream fs = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)) if (document.Load(fs)) { result = new PackageMeta(); PropertyMapper.Assign(result, document, true, true); return(true); } else if (logger != null) { foreach (string error in document.Errors) { logger.Error(error); } } } catch (Exception er) { if (logger != null) { logger.Error(er.Message); } } result = null; return(false); }
public RuntimeInstance() { this.logSystem = new PrimordialLogSystem(); this.configuration = new ExtendedProperties(); this.vmFactory = new VelocimacroFactory(this); this.introspector = new Introspector(this); this.applicationAttributes = new Hashtable(); }
public LogManager(ILogSystem factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } _factory = factory; }
/// <summary> /// Логгер /// </summary> /// <param name="factory"></param> /// <param name="loggerName">Имя лога.</param> internal Logger(ILogSystem factory, string loggerName = null) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } Name = loggerName; _logger = factory.CreateLogger(Name); }
private void initializeLogger() { if (this.logSystem is PrimordialLogSystem) { PrimordialLogSystem primordialLogSystem = (PrimordialLogSystem)this.logSystem; this.logSystem = new NullLogSystem(); if (this.logSystem == null) { this.logSystem = new NullLogSystem(); } else { primordialLogSystem.DumpLogMessages(this.logSystem); } } }
/// <summary> /// dumps the log messages this logger is holding into a new logger /// </summary> public void DumpLogMessages(ILogSystem newLogger) { lock (this) { if (!(pendingMessages.Count == 0)) { // iterate and log each individual message... foreach (Object[] data in pendingMessages) { newLogger.LogVelocityMessage(((LogLevel)data[0]), (String)data[1]); } } pendingMessages.Clear(); } }
private static void Factory() { _fileSystem = FileSystem.Default; _notificationSystem = new ConsoleNotificationSystem(); _disk = new DiskConfigurator(_fileSystem, _notificationSystem); switch (OS.GetCurrent()) { case "win": _path = new PathsConfigurator(CommandSystem.Win, _fileSystem); _bridgeSystem = BridgeSystem.Bat; _colorify = new Format(Theme.Dark); break; case "mac": _path = new PathsConfigurator(CommandSystem.Mac, _fileSystem); _bridgeSystem = BridgeSystem.Bash; _colorify = new Format(Theme.Light); break; } _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem); _logSystem = new FileLogTxt(_fileSystem, _path.Combine("~"), ".hardhat.log"); }
/// <summary> /// Логгер /// </summary> /// <param name="factory">Фабрика, создающая конкретный логгер.</param> /// <param name="sourceName">Название источника лога.</param> /// <param name="loggerName">Имя лога.</param> internal Logger(ILogSystem factory, string sourceName, string loggerName = null) { _factory = factory; try { _logger = _factory != null ? _factory.CreateLogger(sourceName, loggerName) ?? new NullLogger() : new NullLogger(); } catch (Exception ex) { #if DEBUG try { Console.WriteLine(ex); } catch (IOException) { } #endif _logger = new NullLogger(); } }
public static Logger GetLogger(ILogSystem factory, string sourceName, string loggerName) { return new Logger(factory, sourceName, loggerName); }
public static void RegisterLogSystem(ILogSystem factory) { _logFactory = factory; }
/// <summary> Only classes in this package should be creating this. /// Users should not have to mess with this class. /// </summary> /// <param name="wrapMe"> /// </param> protected internal LogChuteSystem(ILogSystem wrapMe) { this.logSystem = wrapMe; }
/// <summary> /// Loads a metadata object from this http host /// </summary> /// <param name="name">A full qualified package name to obtain metadata for</param> /// <param name="logger">A logging interface to write parser errors to</param> public static async Task <Any <JsonDocument> > GetPackageMeta(this HttpClient http, string name, ILogSystem logger) { HttpResponseMessage response = await http.GetAsync(name); if (response.IsSuccessStatusCode) { using (StreamBuffer buffer = new StreamBuffer(await response.Content.ReadAsStreamAsync(), 128)) { JsonDocument document = new JsonDocument(); if (document.Load(buffer)) { return(new Any <JsonDocument>(document)); } else { foreach (string error in document.Errors) { logger.Error(error); } } } } else if (response.StatusCode >= System.Net.HttpStatusCode.BadRequest) { logger.Warning(string.Format("{0} failed to fetch repository: {1}", http.BaseAddress, response.StatusCode)); } return(Any <JsonDocument> .Empty); }