/// <summary> /// Initializes a new instance of the <see cref="LoggerWrapper" /> class. /// </summary> /// <param name="provider">The function that provides the value for the <see cref="LoggerWrapper.BaseLogger" /> property.</param> /// <param name="syncRoot">The custom object for thread safe operations.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> is <see langword="null" />. /// </exception> public LoggerWrapper(LoggerProvider provider, object syncRoot = null) : base(syncRoot: syncRoot) { if (provider == null) { throw new ArgumentNullException("provider"); } _PROVIDER = provider; }
/// <summary> /// Creates a new Server instance. /// </summary> /// <param name="version">Version the server is running. <i>(independent of minecraft version)</i></param> public Server(Config config, string version, int serverId) { this.Config = config; ServerImplementationRegistry.RegisterServerImplementations(); this.LoggerProvider = new LoggerProvider(LogLevel.Debug); this.Logger = this.LoggerProvider.CreateLogger($"Server/{this.Id}"); // This stuff down here needs to be looked into Globals.PacketLogger = this.LoggerProvider.CreateLogger("Packets"); PacketDebug.Logger = this.LoggerProvider.CreateLogger("PacketDebug"); Registry.Logger = this.LoggerProvider.CreateLogger("Registry"); this.Port = config.Port; this.Version = version; this.Id = serverId; this.tcpListener = new TcpListener(IPAddress.Any, this.Port); this.clients = new ConcurrentHashSet <Client>(); this.cts = new CancellationTokenSource(); this.chatMessages = new ConcurrentQueue <QueueChat>(); this.placed = new ConcurrentQueue <PlayerBlockPlacement>(); Logger.LogDebug("Initializing command handler..."); this.Commands = new CommandHandler("/"); Logger.LogDebug("Registering commands..."); this.Commands.RegisterCommandClass <MainCommandModule>(); Logger.LogDebug("Registering custom argument parsers..."); this.Commands.AddArgumentParser(new LocationTypeParser()); this.Commands.AddArgumentParser(new PlayerTypeParser()); Logger.LogDebug("Registering command context type..."); this.Commands.RegisterContextType <ObsidianContext>(); Logger.LogDebug("Done registering commands."); this.Events = new MinecraftEventHandler(); this.PluginManager = new PluginManager(Events, this, LoggerProvider.CreateLogger("Plugin Manager")); this.Operators = new OperatorList(this); this.World = new World("world", this); this.Events.PlayerLeave += this.OnPlayerLeave; this.Events.PlayerJoin += this.OnPlayerJoin; this.Events.ServerTick += this.OnServerTick; }
public bool FixAndSave() { bool flag = this.TryFix(); if (flag && (this.logNumber < 100)) { object[] args = new object[] { GetPath(this.tr), Time.frameCount, this.userId, this.logNumber }; LoggerProvider.GetLogger(typeof(PhysicsUtil)).ErrorFormat("NanFixer fix {0} at frame {1}, user: {2}, logNumber: {3}", args); this.logNumber++; } this.SaveState(); return(flag); }
public CommandsSender(EngineService engineService, NetworkService networkService, ComponentAndEventRegistrator componentAndEventRegistrator, SharedEntityRegistry entityRegistry) { this.networkService = networkService; this.entityRegistry = entityRegistry; this.commandCollector = new CommandCollector(); this.logger = LoggerProvider.GetLogger(this); EventCommandCollector eventListener = new EventCommandCollector(this.commandCollector, componentAndEventRegistrator, entityRegistry); ComponentCommandCollector componentListener = new ComponentCommandCollector(this.commandCollector, componentAndEventRegistrator, entityRegistry); engineService.AddFlowListener(this); engineService.AddComponentListener(componentListener); engineService.AddEventListener(eventListener); }
public void Init(NodeAddedEvent evt, NotInitedCharacterShadowNode node, [JoinAll] SingleNode <CharacterShadowCommonSettingsComponent> characterShadowCommonSettings) { if (!node.characterShadowCasters.HasBounds) { LoggerProvider.GetLogger(this).Error("Incorrect character shadow elements on gameObject " + node.characterShadow.gameObject.name); } else { CharacterShadowInternalComponent shadowInternalData = new CharacterShadowInternalComponent(); this.CalculateShadowInternalData(shadowInternalData, node.characterShadow, characterShadowCommonSettings.component); node.Entity.AddComponent(shadowInternalData); } }
public async Task Async_Error_Log_Call_Shoould_Write_File_Expected_Message__And_Path() { string message = LoggerProvider.CreateLogMessage(MessageLength.Normal); string expectedMessage = $"{_dateTimeProviderMock.UtcNow} [ERROR] {message}"; using (var stream = _streamFactoryMock.Create()) { var streamLogger = new StreamLogger(stream, _dateTimeProviderMock, _streamWriterMock); await streamLogger.LogAsync(LogLevel.Error, message); await _streamWriterMock.Received().WriteLineAsync(Arg.Any <Stream>(), Arg.Is(expectedMessage)); } }
public AssetBundleDiskCacheTask(AssetBundleDiskCache _assetBundleDiskCache) { this.assetBundleDiskCache = _assetBundleDiskCache; this.state2action.Add(AssetBundleDiskCacheState.INIT, new Action(this.Initialize)); this.state2action.Add(AssetBundleDiskCacheState.START_LOAD_FROM_HTTP, new Action(this.StartLoadFromHTTP)); this.state2action.Add(AssetBundleDiskCacheState.LOADING_FROM_HTTP, new Action(this.LoadingFromHTTP)); this.state2action.Add(AssetBundleDiskCacheState.START_LOAD_FROM_DISK, new Action(this.StartLoadFromDisk)); this.state2action.Add(AssetBundleDiskCacheState.START_WRITE_TO_DISK, new Action(this.StartWriteToDisk)); this.state2action.Add(AssetBundleDiskCacheState.WRITE_TO_DISK, new Action(this.WriteToDisk)); this.state2action.Add(AssetBundleDiskCacheState.CREATE_ASSETBUNDLE, new Action(this.CreateAssetBundle)); this.state2action.Add(AssetBundleDiskCacheState.COMPLETE, new Action(this.Complete)); this.Log = LoggerProvider.GetLogger(this); }
public Program([NotNull] IApplicationEnvironment appEnv) { Check.NotNull(appEnv, "appEnv"); _projectDir = appEnv.ApplicationBasePath; _rootNamespace = appEnv.ApplicationName; var loggerProvider = new LoggerProvider(name => new ConsoleCommandLogger(name, verbose: true)); var assemblyName = new AssemblyName(appEnv.ApplicationName); var assembly = Assembly.Load(assemblyName); _migrationTool = new MigrationTool(loggerProvider, assembly); }
private ContentManager(Game game, string dataPackageName, string contentPath) { _game = game; _contentPath = contentPath; _loadedPackages = new List <Package>(); _dataPackageNames = new List <string> { dataPackageName }; _logger = LoggerProvider.GetLogger(); }
// Constructors internal Logger(LoggerProvider loggerProvider) { #region Contracts if (loggerProvider == null) { throw new ArgumentException(); } #endregion // Default _loggerProvider = loggerProvider; }
public Server(Game game, string host, ushort port, string configJson) { _logger = LoggerProvider.GetLogger(); _game = game; _serverPort = port; _serverHost = host; _config = Config.LoadFromJson(game, configJson); _blowfishKeys = new Dictionary <ulong, string>(); foreach (var player in _config.Players) { _blowfishKeys.Add(player.Value.PlayerID, player.Value.BlowfishKey); } }
public static void InitDefaultCursor(Texture2D cursorTexture, Vector2 cursorHotspot) { if (cursorTexture != null) { defaultCursorData.hotspot = cursorHotspot; defaultCursorData.texture = cursorTexture; } else { LoggerProvider.GetLogger(typeof(Cursors)).Error("CursorService:InitDefaultCursor argument 'cursorTexture' is null"); defaultCursorData.hotspot = Vector2.zero; defaultCursorData.texture = null; } }
public OperationExecutor([NotNull] object logHandler, [NotNull] IDictionary args) { Check.NotNull(logHandler, nameof(logHandler)); Check.NotNull(args, nameof(args)); var unwrappedLogHandler = ForwardingProxy.Unwrap <IOperationLogHandler>(logHandler); var loggerProvider = new LoggerProvider(name => new CommandLoggerAdapter(name, unwrappedLogHandler)); var targetName = (string)args["targetName"]; var startupTargetName = (string)args["startupTargetName"]; var environment = (string)args["environment"]; var projectDir = (string)args["projectDir"]; var rootNamespace = (string)args["rootNamespace"]; var startupAssembly = Assembly.Load(new AssemblyName(startupTargetName)); Assembly assembly; try { assembly = Assembly.Load(new AssemblyName(targetName)); } catch (Exception ex) { throw new OperationException(CommandsStrings.UnreferencedAssembly(targetName, startupTargetName), ex); } _contextOperations = new LazyRef <DbContextOperations>( () => new DbContextOperations( loggerProvider, assembly, startupAssembly, projectDir, environment)); _databaseOperations = new LazyRef <DatabaseOperations>( () => new DatabaseOperations( loggerProvider, assembly, startupAssembly, environment, projectDir, rootNamespace)); _migrationsOperations = new LazyRef <MigrationsOperations>( () => new MigrationsOperations( loggerProvider, assembly, startupAssembly, environment, projectDir, rootNamespace)); }
static RtMemoryCacheProvider() { Log = LoggerProvider.LoggerFor(typeof(RtMemoryCacheProvider)); ConfiguredCachesProperties = new Dictionary <string, IDictionary <string, string> >(); if (!(ConfigurationManager.GetSection("rtmemorycache") is CacheConfig[] list)) { return; } foreach (var cache in list) { ConfiguredCachesProperties.Add(cache.Region, cache.Properties); } }
private void Log(string message, Exception e) { string str = "ClientUpdateError: " + message; ILog logger = LoggerProvider.GetLogger(this); if (e == null) { logger.Error(str); } else { logger.Error(str, e); } }
private ContentManager(Game game, string gameModeName, string contentPath) { _contentPath = contentPath; _game = game; _logger = LoggerProvider.GetLogger(); GameModeName = gameModeName; _content = new Dictionary <string, Dictionary <string, List <string> > >(); foreach (var contentType in ContentTypes) { _content[contentType] = new Dictionary <string, List <string> >(); } }
static SysCacheProvider() { log = LoggerProvider.LoggerFor(typeof(SysCacheProvider)); caches = new Dictionary <string, ICache>(); var list = ConfigurationManager.GetSection("syscache") as CacheConfig[]; if (list != null) { foreach (CacheConfig cache in list) { caches.Add(cache.Region, new SysCache(cache.Region, cache.Properties)); } } }
public static void AddForceAtPositionSafe(this Rigidbody rigidbody, Vector3 force, Vector3 position) { if (!IsValidVector3(force)) { LoggerProvider.GetLogger(typeof(PhysicsUtil)).WarnFormat("Invalid add force (Vector3, Vector3). Parameter <force> StackTrace:[{0}]", Environment.StackTrace); } else if (!IsValidVector3(position)) { LoggerProvider.GetLogger(typeof(PhysicsUtil)).WarnFormat("Invalid add force (Vector3, Vector3). Parameter <position> StackTrace:[{0}]", Environment.StackTrace); } else { rigidbody.AddForceAtPosition(force, position); } }
private Application(IWindsorContainer container) { ApplicationId = AppSettings.ApplicationId ?? Guid.NewGuid().ToString(); ApplicationType = AppSettings.ApplicationType ?? string.Empty; ApplicationGroup = AppSettings.ApplicationGroup ?? string.Empty; Container = container; LoggerProvider = Container.Resolve<ILoggerProvider>(); Logger = LoggerProvider.GetLogger(ApplicationLoggerName); Logger.Info(string.Format("初始化当前应用程序[{0}]", ApplicationId)); ComponentHost = new ComponentHost(Logger); ComponentHost.Install(Container); }
public DependencyResult CheckNodeReferences() { try { if (DependencyResult == null) { ServiceContext = new ServiceContextOfUser(); } DependencyResult = ServiceContext.Init(); } catch (Exception ex) { LoggerProvider.GetLog4netLogger("ServiceLog").Error(ex.ToString()); } return(DependencyResult); }
private static void ConsoleLoggerTest(LoggerFactory loggerFactory) { var logger = loggerFactory.CreateConsoleLogger(new ConsoleWrapper()); logger.Log(LogLevel.Debug, LoggerProvider.CreateLogMessage(MessageLength.Normal)); logger.Log(LogLevel.Info, LoggerProvider.CreateLogMessage(MessageLength.Normal)); try { logger.Log(LogLevel.Info, LoggerProvider.CreateLogMessage(MessageLength.ExtraLarge)); } catch (Exception ex) { logger.Log(LogLevel.Error, ex.Message); } }
public UnbufferedLoggerProviderTests() { _messagesHandler = new MockHttpMessageHandler(); _provider = new LoggerProvider(new LoggerOptions() { Uri = "http://www.fakeadress.com", SourceName = "LoggerProviderTestSourceName", SourceCategory = "LoggerProviderTestSourceCategory", SourceHost = "LoggerProviderTestSourceHost", IsBuffered = false, HttpMessageHandler = _messagesHandler, }); _logger = _provider.CreateLogger("OverriddenCategory"); }
public static IActionResult Run( [HttpTrigger(AuthorizationLevel.Function, "POST", Route = null)] HttpRequest httpRequest, TraceWriter traceWriter) { IActionResult toReturn = null; LoggerProvider loggerProvider = new LoggerProvider(traceWriter); toReturn = FunctionLogicHarness.Execute <Models.UpdatePersonBody.Person>( httpRequest, new LoggerProvider(traceWriter), PerformPersonValidation, PerformUpdatePerson); return(toReturn); }
static MemoryCacheProvider() { log = LoggerProvider.LoggerFor(typeof(MemoryCacheProvider)); caches = new Dictionary <string, ICache>(); var list = ConfigurationManager.GetSection("memorycache") as CacheConfig[]; if (list == null) { return; } foreach (var cache in list) { caches.Add(cache.Region, new MemoryCache(cache.Region, cache.Properties)); } }
public virtual void Invoke(IList <HandlerInvokeData> otherInvokeArguments) { int count = this.handlerExecutors.Count; for (int i = 0; i < count; i++) { HandlerExecutor executor = this.handlerExecutors[i]; if ((this.handlerVersion == this.Handler.Version) || this.CheckMethodArgumentsIsActual(executor.ArgumentForMethod)) { this.handlerExecutors[i].Execute(); } else if (this.Handler.Mandatory) { LoggerProvider.GetLogger <Flow>().Warn("Mandatory handler skiped by context change " + this.Handler); } } }
public static void Start(string[] args) { int interval = int.Parse(ConfigurationManager.AppSettings["interval"]) * 1000; var user = ConfigurationManager.AppSettings["user"]; var pass = ConfigurationManager.AppSettings["pass"]; var logWriters = new List <ILogBatchWriter>(); if (Environment.UserInteractive) { logWriters.Add(new ConsoleBatchWriter()); } var elasticsearchURL = ConfigurationManager.AppSettings["ElasticsearchUrl"]; var elasticsearchUser = ConfigurationManager.AppSettings["ElasticsearchUser"]; var elasticsearchPass = ConfigurationManager.AppSettings["ElasticsearchPass"]; logWriters.Add(new ElasticsearchBatchWriter(elasticsearchURL, "mailsender", elasticsearchUser, elasticsearchPass)); var loggerProvider = new LoggerProvider((cat, logLevel) => logLevel >= LogLevel.Information, false, new LoggerBatchingProcessor(logWriters)); var gmailSender = new GmailSender(loggerProvider.CreateLogger <GmailSender>(), user, pass); var config = new Config() { SubjectTemplateFileNameSubfix = ConfigurationManager.AppSettings["SubjectTemplateFileNameSubfix"], BodyTemplateFileNameSubfix = ConfigurationManager.AppSettings["BodyTemplateFileNameSubfix"], MailFolderPath = ConfigurationManager.AppSettings["MailFolderPath"], EmailKey = ConfigurationManager.AppSettings["EmailKey"], PurposeKey = ConfigurationManager.AppSettings["PurposeKey"], ProcessedFolderName = ConfigurationManager.AppSettings["ProcessedFolderName"], TemplateFolderPath = ConfigurationManager.AppSettings["TemplateFolderPath"], Interval = interval }; var processor = new EmailTemplateProcessor.EmailTemplateProcessor(gmailSender, loggerProvider.CreateLogger <EmailTemplateProcessor.EmailTemplateProcessor>(), config); if (processor.Start() == false) { return; } if (Environment.UserInteractive == true) { Console.Read(); } }
public void Setup() { var logSettings = new LogSettings { LogLevel = new Dictionary <string, LogLevel> { { "DarkwingDuck", LogLevel.Warning }, { "LaunchpadMcQuack", LogLevel.Trace }, }, IgnoredCategories = new List <string> { "MegaVolt" } }; _logWriterFake = A.Fake <ILogWriter>(); _classUnderTest = new LoggerProvider(logSettings, _logWriterFake); }
public AttackableUnit( IGame game, string model, IStats stats, int collisionRadius = 40, float x = 0, float y = 0, int visionRadius = 0, uint netId = 0 ) : base((Game)game, x, y, collisionRadius, visionRadius, netId) { Logger = LoggerProvider.GetLogger(); Stats = stats; Model = model; CollisionRadius = 40; Stats.AttackSpeedMultiplier.BaseValue = 1.0f; }
private static void ConfigureLog4Net() { var hierarchy = (Hierarchy)LogManager.GetRepository(typeof(TestsContext).Assembly); var consoleAppender = new ConsoleAppender { Layout = new PatternLayout("%d{ABSOLUTE} %-5p %c{1}:%L - %m%n"), }; hierarchy.Root.Level = log4net.Core.Level.Warn; hierarchy.Root.AddAppender(consoleAppender); hierarchy.Configured = true; #if !NETFX #pragma warning disable 618 LoggerProvider.SetLoggersFactory(new Log4NetLoggerFactory()); #pragma warning restore 618 #endif }
public Program([NotNull] IServiceProvider serviceProvider, [NotNull] IApplicationEnvironment appEnv, [NotNull] ILibraryManager libraryManager) { Check.NotNull(serviceProvider, nameof(serviceProvider)); Check.NotNull(appEnv, nameof(appEnv)); Check.NotNull(libraryManager, nameof(libraryManager)); _projectDir = appEnv.ApplicationBasePath; _rootNamespace = appEnv.ApplicationName; var loggerProvider = new LoggerProvider(name => new ConsoleCommandLogger(name, verbose: true)); var assemblyName = new AssemblyName(appEnv.ApplicationName); var assembly = Assembly.Load(assemblyName); _migrationTool = new MigrationTool(loggerProvider, assembly); _databaseTool = new DatabaseTool(serviceProvider, loggerProvider); _libraryManager = libraryManager; }
public UnbufferedLoggerProviderTests() { _messagesHandler = new MockHttpMessageHandler(); _provider = new LoggerProvider(new LoggerOptions() { Uri = "http://www.fakeadress.com", SourceName = "LoggerProviderTestSourceName", SourceCategory = "LoggerProviderTestSourceCategory", SourceHost = "LoggerProviderTestSourceHost", IsBuffered = false, HttpMessageHandler = _messagesHandler, MinLogLevel = LogLevel.Debug, MessageFormatterFunc = (message, ex, category, level, scopedProperties) => message }); _logger = _provider.CreateLogger("OverriddenCategory"); }
/// <summary> /// Initializes a new instance of the <see cref="FallbackLogger" /> class. /// </summary> /// <param name="baseProvider">The function that provides the main / base logger.</param> /// <param name="fallbackLogger">The fallback logger.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="baseProvider" /> and/or <paramref name="fallbackLogger" /> is <see langword="null" />. /// </exception> public FallbackLogger(LoggerProvider baseProvider, ILogger fallbackLogger) : this(baseProvider: baseProvider, fallbackProvider: CreateProvider(fallbackLogger)) { }
/// <summary> /// Sets the function that provides the value for <see cref="Logger.Current" /> property. /// </summary> /// <param name="provider">The new provider.</param> public static void SetProvider(LoggerProvider provider) { _provider = provider; }
/// <summary> /// Initializes a new instance of the <see cref="SynchronizedLogger" /> class. /// </summary> /// <param name="provider">The function that provides the value for the <see cref="LoggerWrapper.BaseLogger" /> property.</param> /// <param name="syncRoot">The custom object for thread safe operations.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> is <see langword="null" />. /// </exception> public SynchronizedLogger(LoggerProvider provider, object syncRoot = null) : base(provider: provider, syncRoot: syncRoot) { }
/// <summary> /// Initializes a new instance of the <see cref="FallbackLogger" /> class. /// </summary> /// <param name="baseProvider">The function that provides the main / base logger.</param> /// <param name="fallbackProvider">The function that provides the fallback logger.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="baseProvider" /> and/or <paramref name="fallbackProvider" /> is <see langword="null" />. /// </exception> public FallbackLogger(LoggerProvider baseProvider, LoggerProvider fallbackProvider) : base(provider: baseProvider) { if (fallbackProvider == null) { throw new ArgumentNullException("fallbackProvider"); } _FALLBACK_PROVIDER = fallbackProvider; }
/// <summary> /// Initializes a new instance of the <see cref="AsyncLogger" /> class. /// </summary> /// <param name="provider">The function that provides the value for the <see cref="LoggerWrapper.BaseLogger" /> property.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> is <see langword="null" />. /// </exception> public AsyncLogger(LoggerProvider provider) : base(provider: provider) { }
/// <summary> /// Initializes a new instance of the <see cref="FallbackLogger" /> class. /// </summary> /// <param name="baseLogger">The main / base logger.</param> /// <param name="fallbackProvider">The function that provides the fallback logger.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="baseLogger" /> and/or <paramref name="fallbackProvider" /> is <see langword="null" />. /// </exception> public FallbackLogger(ILogger baseLogger, LoggerProvider fallbackProvider) : this(baseProvider: CreateProvider(baseLogger), fallbackProvider: fallbackProvider) { }