/// <summary> /// Creates a new logging adapter using the specified context's event stream. /// </summary> /// <param name="context">The context used to configure the logging adapter.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(this IActorContext context, ILogMessageFormatter logMessageFormatter = null) { var logSource = context.Self.ToString(); var logClass = context.Props.Type; return(new BusLogging(context.System.EventStream, logSource, logClass, logMessageFormatter ?? new DefaultLogMessageFormatter())); }
/// <summary> /// Creates an instance of the LoggingAdapterBase. /// </summary> /// <param name="logMessageFormatter">The log message formatter used by this logging adapter.</param> /// <exception cref="ArgumentNullException">This exception is thrown when the supplied message formatter is null.</exception> protected LoggingAdapterBase(ILogMessageFormatter logMessageFormatter) { if(logMessageFormatter == null) throw new ArgumentNullException("logMessageFormatter", "The message formatter must not be null."); _logMessageFormatter = logMessageFormatter; }
public Log(TextWriter stdout, TextWriter stderr, LogOptions logOptions, ILogMessageFormatter logMessageFormatter) { Stdout = stdout; Stderr = stderr; LogOptions = logOptions; LogMessageFormatter = logMessageFormatter; }
public TeamCityLog(TextWriter output, LogOptions logOptions, ILogMessageFormatter logMessageFormatter) : base(output, output, logOptions, logMessageFormatter) { Output = output; LogOptions = logOptions; TeamCityFormatter = new TeamCityFormatter(); }
/// <summary> /// Creates an instance of the LoggingAdapterBase. /// </summary> /// <param name="logMessageFormatter">The log message formatter used by this logging adapter.</param> /// <exception cref="ArgumentException"></exception> protected LoggingAdapterBase(ILogMessageFormatter logMessageFormatter) { if(logMessageFormatter == null) throw new ArgumentException("logMessageFormatter"); _logMessageFormatter = logMessageFormatter; }
public Log(LogLevel logLevel, ILogMessageFormatter logMessageFormatter) { Stdout = Console.Out; Stderr = Console.Error; LogLevel = logLevel; LogMessageFormatter = logMessageFormatter; }
protected LoggingAdapterBase(ILogMessageFormatter logMessageFormatter) { if (logMessageFormatter == null) { throw new ArgumentException("logMessageFormatter"); } _logMessageFormatter = logMessageFormatter; }
/// <summary> /// Creates an instance of the LoggingAdapterBase. /// </summary> /// <param name="logMessageFormatter">The log message formatter used by this logging adapter.</param> /// <exception cref="ArgumentNullException">This exception is thrown when the given <paramref name="logMessageFormatter"/> is undefined.</exception> protected LoggingAdapterBase(ILogMessageFormatter logMessageFormatter) { if (logMessageFormatter == null) { throw new ArgumentNullException(nameof(logMessageFormatter), "The message formatter must not be null."); } _logMessageFormatter = logMessageFormatter; }
/// <summary> /// Create a new <see cref="ReceiveActorEx"/>. /// </summary> protected ReceiveActorEx() { _log = new Lazy <ILoggingAdapter>(() => { ILogMessageFormatter logMessageFormatter = CreateLogMessageFormatter() ?? new DefaultLogMessageFormatter(); return(Context.GetLogger(logMessageFormatter)); }); }
/// <summary> /// Creates a new logging adapter using the specified context's event stream. /// </summary> /// <param name="context">The context used to configure the logging adapter.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(this IActorContext context, ILogMessageFormatter logMessageFormatter = null) { // if we're runing Akka.Remote or Akka.Cluster, this will grab the default inbound listening address // otherwise, it'll default to just using the local absolute path var addr = ((ExtendedActorSystem)context.System).Provider.DefaultAddress ?? Address.AllSystems; var logSource = addr.Equals(Address.AllSystems) ? context.Self.ToString() : context.Self.Path.ToSerializationFormatWithAddress(addr); var logClass = context.Props.Type; return(new BusLogging(context.System.EventStream, logSource, logClass, logMessageFormatter ?? new DefaultLogMessageFormatter())); }
/// <summary> /// Initializes a new instance of the <see cref="BusLogging" /> class. /// </summary> /// <param name="bus">The logging bus instance that messages will be published to.</param> /// <param name="logSource">The log source.</param> /// <param name="logClass">The log class.</param> /// <param name="logMessageFormatter">The log message formatter.</param> public BusLogging(LoggingBus bus, string logSource, Type logClass, ILogMessageFormatter logMessageFormatter) : base(logMessageFormatter) { _bus = bus; _logSource = logSource; _logClass = logClass; _isErrorEnabled = bus.LogLevel <= LogLevel.ErrorLevel; _isWarningEnabled = bus.LogLevel <= LogLevel.WarningLevel; _isInfoEnabled = bus.LogLevel <= LogLevel.InfoLevel; _isDebugEnabled = bus.LogLevel <= LogLevel.DebugLevel; }
/// <summary> /// INTERNAL API. /// /// Used by actors / infrastructure that are starting up around the same time as the RemoteTransport /// is being booted, and therefore can cause problems similar to https://github.com/akkadotnet/akka.net/issues/4677 at startup. /// </summary> /// <param name="context">The context used to configure the logging adapter.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> internal static ILoggingAdapter GetLoggerStartup(this IActorContext context, ILogMessageFormatter logMessageFormatter = null) { try { return(context.GetLogger(logMessageFormatter)); } catch // had a failure, don't want to propagate it. Just start the logger without remote context { var logSource = LogSource.Create(context); return(new BusLogging(context.System.EventStream, logSource.Source, logSource.Type, logMessageFormatter ?? new DefaultLogMessageFormatter())); } }
/// <summary> /// Creates a new logging adapter using the specified system's event stream. /// </summary> /// <param name="system">The system used to configure the logging adapter.</param> /// <param name="logSourceObj">The source that produces the log events.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(ActorSystem system, object logSourceObj, ILogMessageFormatter logMessageFormatter = null) { return(GetLogger(system.EventStream, logSourceObj, logMessageFormatter)); }
/// <summary> /// Initializes an instance of the LogMessage with the specified formatter, format and args. /// </summary> /// <param name="formatter">The formatter for the LogMessage.</param> /// <param name="format">The string format of the LogMessage.</param> /// <param name="args">The format args of the LogMessage.</param> public LogMessage(ILogMessageFormatter formatter, string format, params object[] args) { _formatter = formatter; Format = format; Args = args; }
public TeamCity5Log(TextWriter output, LogOptions logOptions, ILogMessageFormatter logMessageFormatter) : base(output, logOptions, logMessageFormatter) { }
/// <summary> /// Creates a new logging adapter that writes to the specified logging bus. /// </summary> /// <param name="loggingBus">The bus on which this logger writes.</param> /// <param name="logSourceObj">The source that produces the log events.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(LoggingBus loggingBus, object logSourceObj, ILogMessageFormatter logMessageFormatter = null) { var logSource = LogSource.Create(logSourceObj); return(new BusLogging(loggingBus, logSource.Source, logSource.Type, logMessageFormatter ?? new DefaultLogMessageFormatter())); }
/// <summary> /// Creates a new logging adapter using the specified system's event stream. /// </summary> /// <param name="system">The system used to configure the logging adapter.</param> /// <param name="logSourceObj">The source that produces the log events.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(ActorSystem system, object logSourceObj, ILogMessageFormatter logMessageFormatter = null) { var logSource = LogSource.Create(logSourceObj, system); return(new BusLogging(system.EventStream, logSource.Source, logSource.Type, logMessageFormatter ?? new DefaultLogMessageFormatter())); }
/// <summary> /// Creates a new logging adapter using the specified context's event stream. /// </summary> /// <param name="context">The context used to configure the logging adapter.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(this IActorContext context, ILogMessageFormatter logMessageFormatter = null) { var logSource = LogSource.Create(context, context.System); return(new BusLogging(context.System.EventStream, logSource.Source, logSource.Type, logMessageFormatter ?? new DefaultLogMessageFormatter())); }
/// <summary> /// Creates a new logging adapter that writes to the specified logging bus. /// </summary> /// <param name="loggingBus">The bus on which this logger writes.</param> /// <param name="logSourceObj">The source that produces the log events.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(LoggingBus loggingBus, object logSourceObj, ILogMessageFormatter logMessageFormatter = null) { //TODO: refine this string logSource; Type logClass; if (logSourceObj is string) { logSource = (string)logSourceObj; logClass = typeof(DummyClassForStringSources); } else { logSource = logSourceObj.ToString(); if (logSourceObj is Type) { logClass = (Type)logSourceObj; } else { logClass = logSourceObj.GetType(); } } return(new BusLogging(loggingBus, logSource, logClass, logMessageFormatter ?? new DefaultLogMessageFormatter())); }