public void OutStats(ILogContext context) { Hashtable createdItemsHash = new Hashtable(); Hashtable disposedItemsHash = new Hashtable(); lock (createdSync) { createdItemsHash = this.createdItems.toHash <ItemType, int>(); } lock (disposedSync) { disposedItemsHash = this.disposedItems.toHash <ItemType, int>(); } Hashtable resultInfo = new Hashtable { { "Created Items", createdItemsHash }, { "Disposed Items", disposedItemsHash }, { "Worlds", MmoWorldCache.Instance(m_App).GetStats() } }; var builder = resultInfo.ToStringBuilder(); context.Log(LogFilter.STATS, builder.ToString()); }
/// <summary> /// 初始化一个<see cref="LogBase{TContent}"/>类型的实例 /// </summary> /// <param name="name">名称</param> /// <param name="provider">日志提供程序</param> /// <param name="context">日志上下文</param> /// <param name="session">用户会话</param> protected LogBase(string name, ILogProvider provider, ILogContext context, Bing.Sessions.ISession session) { Provider = provider; Context = context; Session = session ?? Bing.Sessions.NullSession.Instance; Name = name; }
public void Error(ILogContext context, string msg) { if (_settings.IsContextEnabled(context)) { Debug.unityLogger.Log(LogType.Error, context.ToString(), msg); } }
public void AssertFormat <T1, T2, T3, T4, T5>(ILogContext context, string msg, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { if (_settings.IsContextEnabled(context)) { Debug.unityLogger.Log(LogType.Assert, context.ToString(), string.Format(msg, arg1, arg2, arg3, arg4, arg5)); } }
public void AssertFormat(ILogContext context, string msg, params object[] args) { if (_settings.IsContextEnabled(context)) { Debug.unityLogger.Log(LogType.Assert, context.ToString(), string.Format(msg, args)); } }
public void WarningFormat <T1, T2, T3, T4>(ILogContext context, string msg, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { if (_settings.IsContextEnabled(context)) { Debug.unityLogger.Log(LogType.Warning, context.ToString(), string.Format(msg, arg1, arg2, arg3, arg4)); } }
public void AssertFormat <T1>(ILogContext context, string msg, T1 arg1) { if (_settings.IsContextEnabled(context)) { Debug.unityLogger.Log(LogType.Assert, context.ToString(), string.Format(msg, arg1)); } }
public void MessageFormat <T1, T2, T3>(ILogContext context, string msg, T1 arg1, T2 arg2, T3 arg3) { if (_settings.IsContextEnabled(context)) { Debug.unityLogger.Log(LogType.Log, context.ToString(), string.Format(msg, arg1, arg2, arg3)); } }
public static void SetCurrentIfNull(ILogContext context) { if (Current == null) { Current = context; } }
private string GetLogAfter(IEnumerable <IValidationRule> mergedRules, ILogContext logContext) { var sb = new StringBuilder(); sb.AppendLine(); sb.Append("AFTER MERGE:"); var propertyRules = mergedRules.OfType <PropertyRule>().ToArray(); var allProperties = propertyRules.Select(mr => (PropertyInfo)mr.Member).Distinct(); foreach (var property in allProperties) { IPropertyInformation actualProperty = PropertyInfoAdapter.Create(property); var propertyRulesForMember = propertyRules.Where(pr => (PropertyInfoAdapter.Create((PropertyInfo)pr.Member)).Equals(actualProperty)).ToArray(); var validators = propertyRulesForMember.SelectMany(pr => pr.Validators).ToArray(); var logContextInfos = propertyRulesForMember.SelectMany(logContext.GetLogContextInfos).ToArray(); AppendPropertyRuleOutput(actualProperty, validators, logContextInfos, sb); } foreach (var validationRule in mergedRules.Except(propertyRules)) { AppendValidationRuleOutput(validationRule, sb, logContext); } return(sb.ToString()); }
public void ErrorFormat <T1, T2>(ILogContext context, string msg, T1 arg1, T2 arg2) { if (_settings.IsContextEnabled(context)) { Debug.unityLogger.Log(LogType.Error, context.ToString(), string.Format(msg, arg1, arg2)); } }
public ProcessorLockContext(EventProcessorClient client, ILogContext logContext, TimeSpan timeout, ushort maxCount, Func <PartitionInitializingEventArgs, Task> partitionInitializingHandler, Func <PartitionClosingEventArgs, Task> partitionClosingHandler) { _logContext = logContext; _timeout = timeout; _maxCount = maxCount; client.PartitionInitializingAsync += async e => { await OnPartitionInitializing(e).ConfigureAwait(false); if (partitionInitializingHandler != null) { await partitionInitializingHandler(e).ConfigureAwait(false); } }; client.PartitionClosingAsync += async e => { await OnPartitionClosing(e).ConfigureAwait(false); if (partitionClosingHandler != null) { await partitionClosingHandler(e).ConfigureAwait(false); } }; }
public void Log(LogLevel level, string message, ILogContext logContext, Exception exception = null) { var objMessage = logContext.ToString(); string logMessage = string.Format("Message: {0} {1} {2}", message, Environment.NewLine, objMessage); LogMessage(level, logMessage, exception); }
protected BusLogContext(DiagnosticSource source, ILoggerFactory loggerFactory, ILogContext messageLogger, ILogger logger) { _source = source; _loggerFactory = loggerFactory; _messageLogger = messageLogger; _logger = logger; }
public void ShouldRaiseTestLogMessageForRootedScope() { ILogContext tc = null; LogMessageCommandArgs logMessageArg = null; var listener = new Mock <ICommandsListener>(); listener.Setup(o => o.Initialize(It.IsAny <ICommandsSource>())).Callback <ICommandsSource>(s => { s.OnLogMessageCommand += (a, b) => { tc = a; logMessageArg = b; }; }); var extensionManager = new ExtensionManager(); extensionManager.CommandsListeners.Add(listener.Object); var testContext = new TestContext(extensionManager, new CommandsSource(new List <ICommandsListener> { listener.Object })); testContext.Log.Info("qwe"); tc.Should().Be(testContext); logMessageArg.LogMessage.Message.Should().Be("qwe"); logMessageArg.LogMessage.Level.Should().Be(LogMessageLevel.Info); logMessageArg.LogScope.Should().BeNull(); }
public Handle(HostHandle hostHandle, IBus bus, IBusObserver busObserver, ILogContext logContext) { _bus = bus; _busObserver = busObserver; _logContext = logContext; _hostHandle = hostHandle; }
public void ShouldRaiseLaunchLogMessageForInnerScope() { ILogContext lc = null; LogMessageCommandArgs logMessageArg = null; var listener = new Mock <ICommandsListener>(); listener.Setup(o => o.Initialize(It.IsAny <ICommandsSource>())).Callback <ICommandsSource>(s => { s.OnLogMessageCommand += (a, b) => { lc = a; logMessageArg = b; }; }); var extensionManager = new ExtensionManager(); extensionManager.CommandsListeners.Add(listener.Object); var launchContext = new LaunchContext(extensionManager, new CommandsSource(new List <ICommandsListener> { listener.Object })); var scope = launchContext.Log.BeginScope("qwe"); launchContext.Log.Info("asd"); lc.Should().Be(launchContext); logMessageArg.LogMessage.Message.Should().Be("asd"); logMessageArg.LogScope.Should().Be(launchContext.Log); }
public void ShouldRaiseTestEndScope() { ILogContext tc = null; ILogScope logScope = null; var listener = new Mock <ICommandsListener>(); listener.Setup(o => o.Initialize(It.IsAny <ICommandsSource>())).Callback <ICommandsSource>(s => { s.OnEndLogScopeCommand += (a, b) => { tc = a; logScope = b.LogScope; }; }); var extensionManager = new ExtensionManager(); extensionManager.CommandsListeners.Add(listener.Object); var testContext = new TestContext(extensionManager, new CommandsSource(new List <ICommandsListener> { listener.Object })); var scope = testContext.Log.BeginScope("qwe"); scope.Dispose(); tc.Should().Be(testContext); logScope.Name.Should().Be("qwe"); logScope.EndTime.Should().BeCloseTo(DateTime.UtcNow); }
public NetFilterEncryption(byte[] sessionKey, ILogContext log) { DebugLog.Assert(sessionKey.Length == 32, nameof(NetFilterEncryption), "AES session key was not 32 bytes!"); this.sessionKey = sessionKey; this.log = log ?? throw new ArgumentNullException(nameof(log)); }
public void ShouldRaiseLaunchBeginNewScope() { ILogContext lc = null; ILogScope logScope = null; var listener = new Mock <ICommandsListener>(); listener.Setup(o => o.Initialize(It.IsAny <ICommandsSource>())).Callback <ICommandsSource>(s => { s.OnBeginLogScopeCommand += (a, b) => { lc = a; logScope = b.LogScope; }; }); var extensionManager = new ExtensionManager(); extensionManager.CommandsListeners.Add(listener.Object); var launchContext = new LaunchContext(extensionManager, new CommandsSource(new List <ICommandsListener> { listener.Object })); launchContext.Log.BeginScope("qwe"); lc.Should().Be(launchContext); logScope.Name.Should().Be("qwe"); logScope.Context.Should().Be(launchContext); }
public MediatorPublishEndpoint(MediatorSendEndpoint sendEndpoint, IReceiveEndpointConfiguration configuration, IReceivePipeDispatcher dispatcher, ILogContext logContext, SendObservable sendObservers, IReceiveEndpointConfiguration sourceConfiguration) : this(configuration, dispatcher, logContext, sendObservers) { _sourceAddress = sourceConfiguration.InputAddress; _sendEndpoint = sendEndpoint; }
protected BaseReceiveEndpointContext(IHostConfiguration hostConfiguration, IReceiveEndpointConfiguration configuration) { InputAddress = configuration.InputAddress; HostAddress = configuration.HostAddress; _publishTopology = configuration.Topology.Publish; ConsumePipeSpecification = configuration.Consume.Specification; _logContext = LogContext.Current.CreateLogContext(LogCategoryName.Transport.Receive); SendObservers = new SendObservable(); PublishObservers = new PublishObservable(); _endpointObservers = configuration.EndpointObservers; _receiveObservers = configuration.ReceiveObservers; _transportObservers = configuration.TransportObservers; Dependencies = configuration.Dependencies; _sendPipe = new Lazy <ISendPipe>(() => configuration.Send.CreatePipe()); _publishPipe = new Lazy <IPublishPipe>(() => configuration.Publish.CreatePipe()); _receivePipe = new Lazy <IReceivePipe>(configuration.CreateReceivePipe); _serializer = new Lazy <IMessageSerializer>(() => configuration.Serialization.Serializer); _sendEndpointProvider = new Lazy <ISendEndpointProvider>(CreateSendEndpointProvider); _publishEndpointProvider = new Lazy <IPublishEndpointProvider>(CreatePublishEndpointProvider); _sendTransportProvider = new Lazy <ISendTransportProvider>(CreateSendTransportProvider); _publishTransportProvider = new Lazy <IPublishTransportProvider>(CreatePublishTransportProvider); hostConfiguration.ConnectReceiveContextContext(this); }
/// <summary> /// 启动引擎 /// </summary> public static void BootEngine(EngineParam engineParam) { #region 配置服务初始化 IAppConfigManage appConfig = Get <IAppConfigManage>(); AppConfigParam appConfigParam = new AppConfigParam() { UserConfigPath = engineParam.AppConfigPath }; appConfig.LoadConfigs(appConfigParam); #endregion #region 日志服务初始化 ILogContext log = Get <ILogContext>(); log.Init(@engineParam.LogConfigPath); #endregion #region 缓存服务初始化 ScrapyCachePool cache = Get <ICachePool>() as ScrapyCachePool; cache.Init(); ScrapyCachePool.LogDebugEvent += ScrapyCacheLogForDebug; ScrapyCachePool.LogInfoEvent += ScrapyCacheLogForInfo; ScrapyCachePool.LogErrorEvent += ScrapyCacheLogForError; //客户端缓存配置表 cache.Get <ClientCacheConfigTable>().LoadDatas(appConfig.CacheLogConfig.基础组缓存表); cache.Get <ClientCacheConfigTable>().LoadDatas(appConfig.CacheLogConfig.衍生品缓存表); cache.Get <ClientCacheConfigTable>().LoadDatas(appConfig.CacheLogConfig.权益缓存表); cache.Get <ClientCacheConfigTable>().LoadDatas(appConfig.CacheLogConfig.固收缓存表); //客户端缓存列配置表 cache.Get <ClientCacheConfigColumnTable>().LoadDatas(appConfig.CacheLogConfig.基础组缓存字段表); cache.Get <ClientCacheConfigColumnTable>().LoadDatas(appConfig.CacheLogConfig.衍生品缓存字段表); cache.Get <ClientCacheConfigColumnTable>().LoadDatas(appConfig.CacheLogConfig.权益缓存字段表); cache.Get <ClientCacheConfigColumnTable>().LoadDatas(appConfig.CacheLogConfig.固收缓存字段表); #endregion }
/// <summary> /// 消息寫入日誌的詳細處理 /// </summary> /// <param name="logLevel">日誌處理級別</param> /// <param name="message">日誌信息<see cref="ILogContext"/>自定義的屬性消息,寫入到<see cref="LogEventInfo.Properties"/></param> /// <param name="exception">異常對象</param> protected override void WriteInternal(Common.Logging.LogLevel logLevel, object message, Exception exception) { LogLevel level = GetLevel(logLevel); ILogContext context = message as ILogContext; object messageText = context == null ? message : context.Message; LogEventInfo logEvent = new LogEventInfo(level, _logger.Name, null, "{0}", new object[1] { messageText }, exception); context?.Properties.ToList().ForEach(logEvent.Properties.Add); StackTrace st = new StackTrace(0); int index = 0; StackFrame[] frames = st.GetFrames(); foreach (StackFrame sf in frames) { MethodBase mb = sf.GetMethod(); Type dt = mb.DeclaringType; if (dt == null || ExcludeTypes.Contains(dt) || ExcludeAssemblies.Contains(dt.Assembly) || ExcludeNameSpaces.Contains(dt.Namespace)) { index++; continue; } logEvent.SetStackTrace(st, index); break; } _logger.Log(GetType(), logEvent); }
public DatabaseLogger(ILogRepository logRepository, ILogService logService, ILogContext logContext, IEventRepository eventRepository, IAgentService agentService) { this.logRepository = logRepository; this.agentService = agentService; this.logService = logService; this.logContext = logContext; this.eventRepository = eventRepository; }
public SendTransportContext(IModelContextSupervisor modelContextSupervisor, IPipe <ModelContext> configureTopologyPipe, string exchange, ILogContext logContext) : base(logContext) { ModelContextSupervisor = modelContextSupervisor; ConfigureTopologyPipe = configureTopologyPipe; Exchange = exchange; }
protected virtual void Dispose(bool disposing) { if (Current == this) { Current = _previous; _previous = null; } }
/// <summary> /// 初始化一个<see cref="LogBase{TContent}"/>类型的实例 /// </summary> /// <param name="provider">日志提供程序</param> /// <param name="context">日志上下文</param> /// <param name="currentUser">当前用户</param> protected LogBase(ILogProvider provider , ILogContext context , ICurrentUser currentUser) { Provider = provider; Context = context; CurrentUser = currentUser ?? NullCurrentUser.Instance; }
BusLogContext(DiagnosticSource source, ILoggerFactory loggerFactory, ILogger logger) { _source = source; _loggerFactory = loggerFactory; _logger = logger; _messageLogger = this; }
protected BusLogContext(DiagnosticListener source, bool enabled, ILoggerFactory loggerFactory, ILogContext messageLogger, ILogger logger) { _source = source; _enabled = enabled; _loggerFactory = loggerFactory; _messageLogger = messageLogger; _logger = logger; }
public LogWriter(ILogContext context, IAuthenticator authenticator, IClock clock) { Contract.Requires<ArgumentNullException>(context != null); Contract.Requires<ArgumentNullException>(authenticator != null); Contract.Requires<ArgumentNullException>(clock != null); _context = context; _authenticator = authenticator; _clock = clock; }
/// <summary> /// Constructor. /// </summary> public BaseControllerArgs( ILogContext logContext, IIdentityProvider identityProvider, IUserProvider userProvider, ITimeZoneProvider timeZoneProvider) { LogContext = logContext; IdentityProvider = identityProvider; UserProvider = userProvider; TimeZoneProvider = timeZoneProvider; }
/// <summary> /// Constructor. /// </summary> public BaseController(BaseControllerArgs args) { LogContext = args.LogContext; TimeZoneProvider = args.TimeZoneProvider; _identityProvider = args.IdentityProvider; _userProvider = args.UserProvider; }
public LogContext(string name) { Name = name; _previous = Current; Current = this; }
public LogReader(ILogContext context) { Context = context; }