本文整理汇总了C#中LogMessageType类的典型用法代码示例。如果您正苦于以下问题:C# LogMessageType类的具体用法?C# LogMessageType怎么用?C# LogMessageType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogMessageType类属于命名空间,在下文中一共展示了LogMessageType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendLog
// Help methods that use our FileSystem abstraction
public override void AppendLog(String message, LogMessageType messageType)
{
string textEntry = string.Format("{0:MM-dd-yyyy HH:mm:ss:ffff} :{1}: [{2}] {3}", DateTime.Now, System.Threading.Thread.CurrentThread.ManagedThreadId, messageType.ToString(), message);
switch (messageType)
{
case LogMessageType.Info:
Android.Util.Log.Info(TAG, message);
break;
case LogMessageType.Warn:
Android.Util.Log.Debug(TAG, message);
break;
case LogMessageType.Debug:
Android.Util.Log.Debug(TAG, message);
break;
case LogMessageType.Error:
Android.Util.Log.Error(TAG, message);
break;
case LogMessageType.Fatal:
Android.Util.Log.Wtf(TAG, message);
break;
case LogMessageType.Metric:
Android.Util.Log.Debug( TAG_METRIC, message );
break;
default:
break;
}
AppendText(LogFileName, textEntry);
}
示例2: Write
/// <summary>
/// Writes a single message to the output.
/// </summary>
/// <param name="source">The <see cref="Log"/> from which the message originates.</param>
/// <param name="type">The type of the log message.</param>
/// <param name="msg">The message to write.</param>
/// <param name="context">The context in which this log was written. Usually the primary object the log entry is associated with.</param>
public virtual void Write(Log source, LogMessageType type, string msg, object context)
{
int indent = source.Indent;
string prefix = source.Prefix ?? "";
string[] lines = msg.Split(new[] { '\n', '\r', '\0' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < lines.Length; i++)
{
if (i == 0)
{
switch (type)
{
case LogMessageType.Message:
lines[i] = prefix + "Msg: " + new string(' ', indent * 2) + lines[i];
break;
case LogMessageType.Warning:
lines[i] = prefix + "Wrn: " + new string(' ', indent * 2) + lines[i];
break;
case LogMessageType.Error:
lines[i] = prefix + "ERR: " + new string(' ', indent * 2) + lines[i];
break;
}
}
else
{
lines[i] = new string(' ', prefix.Length + 5 + indent * 2) + lines[i];
}
this.WriteLine(source, type, lines[i], context);
}
}
示例3: Write
/// <summary>
/// Writes a single message to the output.
/// </summary>
/// <param name="source">The <see cref="Log"/> from which the message originates.</param>
/// <param name="type">The type of the log message.</param>
/// <param name="msg">The message to write.</param>
/// <param name="context">The context in which this log was written. Usually the primary object the log entry is associated with.</param>
public virtual void Write(Log source, LogMessageType type, string msg, object context)
{
int indent = source.Indent;
string[] lines = msg.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < lines.Length; i++)
{
if (i == 0)
{
switch (type)
{
case LogMessageType.Message:
lines[i] = source.Prefix + "Info: " + new string(' ', indent * 4) + lines[i];
break;
case LogMessageType.Warning:
lines[i] = source.Prefix + "Warning: " + new string(' ', indent * 4) + lines[i];
break;
case LogMessageType.Error:
lines[i] = source.Prefix + "ERROR: " + new string(' ', indent * 4) + lines[i];
break;
}
}
else
{
lines[i] = source.Prefix + " " + new string(' ', indent * 4) + lines[i];
}
this.writer.WriteLine(lines[i]);
}
}
示例4: LogMessage
public LogMessage(String message, LogMessageType type, LogMessageSeverity severity, Exception exception)
{
Message = message;
Type = type;
Severity = severity;
Exception = exception;
}
示例5: DoLog
/// <summary>
/// Write Log By MessageType
/// </summary>
/// <param name="message">Message</param>
/// <param name="messageType">MessageType</param>
/// <param name="ex">Exception Object</param>
/// <param name="type">Log Source Type</param>
private static void DoLog(string message, LogMessageType messageType, Exception ex, Type type)
{
string stackTrace = string.Empty;
if (ex != null)
{
stackTrace = ex.StackTrace;
}
_mLog = LogManager.GetLogger(type);
switch (messageType)
{
case LogMessageType.Debug:
//AppLog._mLog.Debug(message + " ExceptionStackTrace:" + stackTrace, ex);//Edit by Gerry
AppLog._mLog.Debug(message + stackTrace, ex);
break;
case LogMessageType.Info:
AppLog._mLog.Info(message + stackTrace, ex);
break;
case LogMessageType.Warn:
AppLog._mLog.Warn(message + stackTrace, ex);
break;
case LogMessageType.Error:
AppLog._mLog.Error(message + stackTrace, ex);
break;
case LogMessageType.Fatal:
AppLog._mLog.Fatal(message + stackTrace, ex);
break;
}
}
示例6: Colorize
void Colorize ( LogMessageType eventType )
{
switch (eventType) {
case LogMessageType.Debug :
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.BackgroundColor = ConsoleColor.Black;
break;
case LogMessageType.Verbose :
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.BackgroundColor = ConsoleColor.Black;
break;
case LogMessageType.Information :
Console.ForegroundColor = ConsoleColor.Gray;
Console.BackgroundColor = ConsoleColor.Black;
break;
case LogMessageType.Warning :
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Black;
break;
case LogMessageType.Error :
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Black;
break;
case LogMessageType.Fatal :
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Red;
break;
}
}
示例7: LogMessage
public LogMessage(string text, DateTime timestamp, string sourceInfo, LogMessageType type)
{
this.text = text;
this.timestamp = timestamp;
this.sourceInfo = sourceInfo;
this.type = type;
}
示例8: LogMessage
/// <summary>
/// Initializes a new instance of the <see cref="LogMessage"/> class.
/// </summary>
/// <param name="content">
/// The content.
/// </param>
/// <param name="messageType">
/// The message type.
/// </param>
/// <param name="logLevel">
/// The log level.
/// </param>
/// <param name="messageIndex">
/// The message Index.
/// </param>
public LogMessage(string content, LogMessageType messageType, LogLevel logLevel, long messageIndex)
{
this.Content = content;
this.MessageType = messageType;
this.LogLevel = logLevel;
this.MessageIndex = messageIndex;
}
示例9: WriteLineTest1
public void WriteLineTest1()
{
LogMessageType messageFlag = new LogMessageType(); // TODO: 初始化为适当的值
string strFormat = string.Empty; // TODO: 初始化为适当的值
object[] arg = null; // TODO: 初始化为适当的值
LOGs.WriteLine( messageFlag, strFormat, arg );
Assert.Inconclusive( "无法验证不返回值的方法。" );
}
示例10: GetWriter
TextWriter GetWriter ( LogMessageType eventType )
{
if ( eventType==LogMessageType.Error || eventType==LogMessageType.Warning || eventType==LogMessageType.Fatal ) {
return Console.Error;
} else {
return Console.Out;
}
}
示例11: AssetLogMessage
/// <summary>
/// Initializes a new instance of the <see cref="AssetLogMessage" /> class.
/// </summary>
/// <param name="package">The package.</param>
/// <param name="assetReference">The asset reference.</param>
/// <param name="type">The type.</param>
/// <param name="messageCode">The message code.</param>
/// <param name="arguments">The arguments.</param>
/// <exception cref="System.ArgumentNullException">asset</exception>
public AssetLogMessage(Package package, IReference assetReference, LogMessageType type, string text)
{
this.package = package;
AssetReference = assetReference;
Type = type;
Related = new List<IReference>();
Text = text;
}
示例12: WriteMessage
public override void WriteMessage(string message, LogMessageType type, Exception exception)
{
if (type == LogMessageType.Error)
System.Threading.Interlocked.Increment(ref ErrorCount);
else if (type == LogMessageType.Warning)
System.Threading.Interlocked.Increment(ref WarningCount);
base.WriteMessage(this.Backupset + ", " + message, type, exception);
}
示例13: AppendLog
// Help methods that use our FileSystem abstraction
public override void AppendLog(String message, LogMessageType messageType)
{
string textEntry = string.Format("{0:MM-dd-yyyy HH:mm:ss:ffff} :{1}: [{2}] {3}", DateTime.Now, System.Threading.Thread.CurrentThread.ManagedThreadId, messageType.ToString(), message);
Console.WriteLine(textEntry);
AppendText(LogFileName, textEntry);
}
示例14: LogMessage
/// <summary>
/// Initializes a new instance of the <see cref="LogMessage" /> class.
/// </summary>
/// <param name="module">The module.</param>
/// <param name="type">The type.</param>
/// <param name="text">The text.</param>
/// <param name="exception">The exception.</param>
/// <param name="callerInfo">The caller info.</param>
public LogMessage(string module, LogMessageType type, string text, Exception exception, CallerInfo callerInfo)
{
Module = module;
Type = type;
Text = text;
Exception = exception;
CallerInfo = callerInfo;
}
示例15: ActivateLog
/// <summary>
/// Activates the log for loggers that match a regex pattern on the module name.
/// </summary>
/// <param name="regexPatternModule">The regex pattern to match a module name.</param>
/// <param name="minimumLevel">The minimum level.</param>
/// <param name="maximumLevel">The maximum level.</param>
/// <param name="enabledFlag">if set to <c>true</c> enaable the log, else disable.</param>
/// <exception cref="ArgumentNullException">If regexPatternModule is null</exception>
public static void ActivateLog(string regexPatternModule, LogMessageType minimumLevel, LogMessageType maximumLevel = LogMessageType.Fatal, bool enabledFlag = true)
{
if (regexPatternModule == null)
throw new ArgumentNullException("regexPatternModule");
var regex = new Regex(regexPatternModule);
ActivateLog(regex, minimumLevel, maximumLevel);
}