本文整理汇总了C#中Logger.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.ToString方法的具体用法?C# Logger.ToString怎么用?C# Logger.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogMessage
public override void LogMessage(Logger.Level level, string logger, string message)
{
var timeStamp = this.IncludeTimeStamps
? "[" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + "] "
: "";
SetForeGroundColor(level);
Console.WriteLine(string.Format("{0}[{1}] [{2}]: {3}", timeStamp, level.ToString().PadLeft(5), logger, message));
}
示例2: LogMessage
/// <summary>
/// Logs a message to a log-file.
/// </summary>
/// <param name="level">Log level.</param>
/// <param name="logger">Source of the log message.</param>
/// <param name="message">Log message.</param>
public override void LogMessage(Logger.Level level, string logger, string message)
{
lock (this) // we need this here until we seperate gs / moonet /raist
{
var timeStamp = this.IncludeTimeStamps ? "[" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + "] " : "";
if (!this._disposed) // make sure we're not disposed.
this._logStream.WriteLine(string.Format("{0}[{1}] [{2}]: {3}", timeStamp, level.ToString().PadLeft(5), logger, message));
}
}
示例3: Log
public override void Log(Logger.Level level, string logger, string message)
{
lock (this)
{
var timeStamp = IncludeTimeStamps ? "[" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + "] " : "";
if (!_disposed) // make sure we're not disposed.
{
m_logStream.WriteLine("{0}[{1}] [{2}]: {3}", timeStamp, level.ToString().PadLeft(5), logger, message);
}
}
}
示例4: LogException
public override void LogException(Logger.Level level, string logger, string message, Exception exception)
{
#if ANDROID
/* In android platform there's no console so we've to instead use Android.Util.Log.
* for more information check: http://docs.xamarin.com/android/advanced_topics/android_debug_log */
var tag = this._callingAssemblyName; // we better tag the logline with assembly name.
switch (level)
{
case Logger.Level.Trace:
Android.Util.Log.Debug(tag, logger + ": " + message + " - [Exception] " + exception);
break;
case Logger.Level.Debug:
Android.Util.Log.Debug(tag, logger + ": " + message + " - [Exception] " + exception);
break;
case Logger.Level.Info:
Android.Util.Log.Info(tag, logger + ": " + message + " - [Exception] " + exception);
break;
case Logger.Level.Warn:
Android.Util.Log.Warn(tag, logger + ": " + message + " - [Exception] " + exception);
break;
case Logger.Level.Error:
Android.Util.Log.Error(tag, logger + ": " + message + " - [Exception] " + exception);
break;
case Logger.Level.Fatal:
Android.Util.Log.Wtf(tag, logger + ": " + message + " - [Exception] " + exception);
break;
default:
throw new ArgumentOutOfRangeException("level");
}
#else
var timeStamp = this.IncludeTimeStamps ? "[" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + "] " : "";
SetForeGroundColor(level);
Console.WriteLine(string.Format("{0}[{1}] [{2}]: {3} - [Exception] {4}", timeStamp, level.ToString().PadLeft(5), logger, message, exception));
#endif
}
示例5: Write
/// <summary>
/// Write the message to the log file, specifying the error level.
/// </summary>
/// <param name="message">The message to write.</param>
/// <param name="level">The error level.</param>
public static void Write(String message, Logger.LogLevel level)
{
if (_LogFile != null && level >= Logger._Level)
{
// Tab indent the entire message
message = "\t" + message;
message.Replace(Environment.NewLine, Environment.NewLine + "\t");
// Display the message in a message box to the user for warnings, errors or fatal errors
if (level == LogLevel.Error || level == LogLevel.Fatal)
{
System.Windows.Forms.MessageBox.Show(message, level.ToString());
}
// Write the message to the log file and flush the stream
_LogFile.Write(DateTime.Now + "\t" + level.ToString() + Environment.NewLine + message + Environment.NewLine);
_LogFile.Flush();
}
}
示例6: LogException
public override void LogException(Logger.Level level, string logger, string message, Exception exception)
{
lock (this)
{
var timeStamp = this.IncludeTimeStamps
? "[" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + "] "
: "";
if (!this._disposed)
this._logStream.WriteLine(string.Format("{0}[{1}] [{2}]: {3} - [Exception] {4}", timeStamp, level.ToString().PadLeft(5), logger, message, exception));
}
}
示例7: Logger_LogEvent
void Logger_LogEvent(Logger.Level level, string message)
{
if (level > Logger.Level.Debug)
{
Console.WriteLine("{0} [{1}] {2}", DateTime.Now, level.ToString().ToUpper(), message);
logFile.WriteLine("{0} [{1}] {2}", DateTime.Now, level.ToString().ToUpper(), message);
}
}
示例8: CargarMensaje
void CargarMensaje(Logger.Mensaje mensaje)
{
tbLog.Text += string.Concat(DateTime.Now.ToString("MM-dd HH:mm:ss"), " ", mensaje.ToString(), Environment.NewLine);
}
示例9: Log
public override void Log(Logger.Level level, string logger, string message, Exception exception)
{
var timeStamp = IncludeTimeStamps ? "[" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + "] " : "";
SetConsoleForegroundColor(level);
Console.WriteLine(string.Format("{0}[{1}] [{2}]: {3} - [Exception] {4}", timeStamp, level.ToString().PadLeft(5), logger, message, exception));
}