5 namespace SiliconStudio.Core.Diagnostics
12 private int logCountFlushLimit;
19 LogCountFlushLimit = 1;
20 TextFormatter = msg => msg.ToString();
27 public int LogMessageCount {
get;
private set; }
33 public bool UseFlushAsync {
get; set; }
38 public Func<ILogMessage, string> TextFormatter {
get; set; }
44 public int LogCountFlushLimit
46 get {
return logCountFlushLimit; }
51 throw new ArgumentException(
"Value must be > 0");
54 logCountFlushLimit = value;
62 protected abstract void OnLog(
ILogMessage logMessage);
72 return (logMessage.
Type >
LogMessageType.Info) || (LogMessageCount % LogCountFlushLimit) == 0;
96 return TextFormatter(logMessage);
107 if (serializableLogMessage != null)
109 return serializableLogMessage.ExceptionInfo != null ? serializableLogMessage.ExceptionInfo.ToString() :
string.Empty;
112 if (logMessage != null)
114 return logMessage.Exception != null ? logMessage.Exception.ToString() :
string.Empty;
116 throw new ArgumentException(
"Unsupported log message.");
124 public static implicit
operator Action<ILogMessage>(
LogListener logListener)
126 return logListener.OnLogInternal;
133 if (ShouldFlush(logMessage))
virtual void Flush()
Flush the log, method to be implemented in a subclass.
virtual void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resourc...
A class that represents a copy of a LogMessage that can be serialized.
LogMessageType
Type of a LogMessage.
virtual string GetExceptionText(ILogMessage message)
Gets the text that describes the exception associated to a particular log message.
virtual string GetDefaultText(ILogMessage logMessage)
Gets the default text for a particular log message.
A base log message used by the logging infrastructure.
A base class to implement a log listener
The base interface for log messages used by the logging infrastructure.
LogMessageType Type
Gets or sets the type of this message.
virtual bool ShouldFlush(ILogMessage logMessage)
Returns a boolean indicating whether the log should be flushed. By default, flushing is occuring if t...
LogListener()
Initializes a new instance of the LogListener class.