public static void LogException(this ILogChannel channel, Exception exception, [CallerMemberName] string callerMemberName = null, [CallerLineNumber] int callerLineNumber = 0, [CallerFilePath] string callerFilePath = null) { //if (channel == null) throw new ArgumentNullException(nameof(channel)); channel.LogException(@exception, null, callerMemberName, callerLineNumber, callerFilePath); }
public static void OnActionExecuted(this ILogChannel loggerEngine, string category, LogLevel level, IActionContext actionContext) { loggerEngine.Log(GetLogString( "Action '{0}' execution has done with folowing information:", level, actionContext, actionContext.ActionDescriptor, true )); }
public static void Log <TValue>(this ILogChannel channel, TValue value, [CallerMemberName] string callerMemberName = null, [CallerLineNumber] int callerLineNumber = 0, [CallerFilePath] string callerFilePath = null) { if (channel == null) { throw new ArgumentNullException(nameof(channel)); } channel.LogString(value?.ToString(), null, callerMemberName, callerLineNumber, callerFilePath); }
public static void AddMyLoggingServices(this IServiceCollection services, IConfiguration config) { if (config.GetValue <bool>("logging:human")) { services.AddSingletonAs(JsonLogWriterFactory.Readable()) .As <IObjectWriterFactory>(); } else { services.AddSingletonAs(JsonLogWriterFactory.Default()) .As <IObjectWriterFactory>(); } var loggingFile = config.GetValue <string>("logging:file"); if (!string.IsNullOrWhiteSpace(loggingFile)) { services.AddSingletonAs(file ?? (file = new FileChannel(loggingFile))) .As <ILogChannel>(); } var useColors = config.GetValue <bool>("logging:colors"); if (console == null) { console = new ConsoleLogChannel(useColors); } services.AddSingletonAs(console) .As <ILogChannel>(); services.AddSingletonAs(c => new ApplicationInfoLogAppender(typeof(Program).Assembly, Guid.NewGuid())) .As <ILogAppender>(); services.AddSingletonAs <ActionContextLogAppender>() .As <ILogAppender>(); services.AddSingletonAs <TimestampLogAppender>() .As <ILogAppender>(); services.AddSingletonAs <DebugLogChannel>() .As <ILogChannel>(); services.AddSingletonAs <SemanticLog>() .As <ISemanticLog>(); services.AddSingletonAs <DefaultAppLogStore>() .As <IAppLogStore>(); services.AddSingletonAs <NoopLogStore>() .As <ILogStore>(); }
public ServiceBusLogger(string endPoint, string issuerName, string issuerKey) { Uri uri = new Uri(endPoint); TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior(); sharedSecretServiceBusCredential.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerKey); ChannelFactory <ILogChannel> channelFactory = new ChannelFactory <ILogChannel>(); channelFactory.Endpoint.Address = new EndpointAddress(uri); channelFactory.Endpoint.Binding = new NetTcpRelayBinding(); channelFactory.Endpoint.Contract.ContractType = typeof(ILogChannel); channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential); this.Channel = channelFactory.CreateChannel(); }
public static void AddMyLoggingServices(this IServiceCollection services, IConfiguration config) { if (config.GetValue <bool>("logging:human")) { services.AddSingletonAs(c => new Func <IObjectWriter>(() => new JsonLogWriter(Formatting.Indented, true))); } else { services.AddSingletonAs(c => new Func <IObjectWriter>(() => new JsonLogWriter())); } var loggingFile = config.GetValue <string>("logging:file"); if (!string.IsNullOrWhiteSpace(loggingFile)) { services.AddSingletonAs(file ?? (file = new FileChannel(loggingFile))) .As <ILogChannel>() .As <IInitializable>(); } services.AddSingletonAs(console) .As <ILogChannel>(); services.AddSingletonAs(c => new ApplicationInfoLogAppender(typeof(Program).Assembly, Guid.NewGuid())) .As <ILogAppender>(); services.AddSingletonAs <ActionContextLogAppender>() .As <ILogAppender>(); services.AddSingletonAs <TimestampLogAppender>() .As <ILogAppender>(); services.AddSingletonAs <DebugLogChannel>() .As <ILogChannel>(); services.AddSingletonAs <SemanticLog>() .As <ISemanticLog>(); services.AddSingletonAs <RequestLogProfilerSessionProvider>() .As <ILogProfilerSessionProvider>() .AsSelf(); }
public static void Error(ILogChannel channel, string message) { var m = channel.Process(message, LogSeverity.Error); Debug.LogError(m); }
public static void Warning(ILogChannel channel, string message) { var m = channel.Process(message, LogSeverity.Warning); Debug.LogWarning(m); }
public static void Info(ILogChannel channel, string message) { var m = channel.Process(message, LogSeverity.Info); Debug.Log(m); }
public static void Setup(ILogChannel channel, LogMode mode) { _activeChannel = channel; _logMode = mode; }
static void ConfigurationChanged(Models.Events.ConfigurationEventArgs args) { // Empty the default values _activeChannel = null; _logMode = LogMode.Error; }
public static void RegisterDefaultLogChannel(ILogChannel logChannel) { _defaultChannel = logChannel; }
/// <summary> /// Check if the channel can process the incoming message. /// </summary> /// <param name="level">The <see cref="LogLevels"/> of the incoming message.</param> /// <returns>True if the incoming message level is in the range that the channel should process, false otherwise.</returns> private static bool CanProcess(ILogChannel channel, LogLevels level) { return(channel.MinimumLogLevel <= level && level <= channel.MaximumLogLevel); }