本文整理汇总了C#中LogLevels类的典型用法代码示例。如果您正苦于以下问题:C# LogLevels类的具体用法?C# LogLevels怎么用?C# LogLevels使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogLevels类属于命名空间,在下文中一共展示了LogLevels类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LogMessage
public LogMessage(string msg)
{
this.level = LogLevels.Verbose;
this.msgText = msg;
this.subject = "unknown";
this.created = DateTime.Now;
}
开发者ID:hapm,项目名称:IrcShark,代码行数:7,代码来源:LogMessage.cs
示例2: LogFile
public static void LogFile(string entry, LogLevels level)
{
if (Silent)
{
return;
}
if (CurrentLevel > (byte)level)
{
return;
}
entry = DateTime.Now.TimeOfDay.ToString() + " " + Convert.ToString(Thread.CurrentThread.ManagedThreadId) + " " + entry;
Queue.Synchronized(logEntriesList).Enqueue(entry);
Monitor.Enter(logThread);
if(!logThread.IsAlive)
{
logThread.Start();
}
Monitor.Exit(logThread);
try
{
sm.Release();
}
catch
{
}
}
开发者ID:vadimsu,项目名称:PACK,代码行数:26,代码来源:LogUtility.cs
示例3: Log
public void Log(LogLevels logLevel, string str)
{
using (var sw = GetStreamWriter())
{
sw.WriteLine("{0}:{1:HH-mm-ss}: {2}", logLevel, DateTime.Now, str);
}
}
开发者ID:welterde,项目名称:MarcidiaMud,代码行数:7,代码来源:FileLogger.cs
示例4: LogWithTags
public static void LogWithTags(this ExceptionlessClient client, string logMessage, string[] tags, string source = null, LogLevels level = LogLevels.Info)
{
if (client.LoggingEnabled())
client.CreateLog(source, logMessage, level.Text())
.AddTags(tags)
.Submit();
}
开发者ID:CodescapeSystems,项目名称:Exceptionless,代码行数:7,代码来源:Extensions.cs
示例5: WriteText
public void WriteText(System.IO.TextWriter writer, LogLevels level, DateTime dateTime, string text)
{
string sLevel;
switch (level)
{
case LogLevels.Info:
default:
sLevel = "I";
break;
case LogLevels.Diagnostic:
sLevel = "D";
break;
case LogLevels.Warning:
sLevel = "W";
break;
case LogLevels.Error:
sLevel = "E";
break;
}
writer.WriteLine("{0}:{1} {2} [{4}]: {3}",
sLevel, dateTime.ToShortDateString(), dateTime.ToLongTimeString(),
text, Thread.CurrentThread.GetHashCode());
}
开发者ID:eleven41,项目名称:Eleven41.Logging,代码行数:27,代码来源:DefaultTextWriterFormatter.cs
示例6: AppendEntry
public void AppendEntry(string sourceDomainName, global::System.Reflection.AssemblyName sourceAssembly, string sourceTypeName, string sourceMethodName, LogLevels level, DateTime timestamp, string message)
{
_logController.AppendEntry(sourceDomainName, sourceAssembly, sourceTypeName, sourceMethodName, level, timestamp, message);
System.sDomain[] doms = System.Domains;
foreach (System.sDomain dom in doms)
dom.Core.AppendEntry(sourceDomainName, sourceAssembly, sourceTypeName, sourceMethodName, level, timestamp, message);
}
开发者ID:roger-castaldo,项目名称:MultiDomain,代码行数:7,代码来源:Core.cs
示例7: Log
public static void Log(LogLevels level, string text)
{
#if LOG
if (!File.Exists(LogPath))
{
File.WriteAllText(LogPath, "Executable: " + Application.ExecutablePath + "\r\n" +
"Version: " + Application.ProductVersion + "\r\n" +
"Installed .Net Framework: " + typeof(object).Assembly.GetName().Version.ToString() + "\r\n" +
"OS: " + Environment.OSVersion.VersionString + "\r\n", Encoding.UTF8);
}
switch (level)
{
case LogLevels.Warning:
text = "[WARN] " + text;
break;
case LogLevels.Error:
text = "[ERRO] " + text;
break;
case LogLevels.Information:
default:
text = "[INFO] " + text;
break;
}
File.AppendAllLines(LogPath, new string[] { text }, Encoding.UTF8);
#endif
}
开发者ID:MusicDemon,项目名称:Warcraft-3-Loader-Form,代码行数:26,代码来源:Logging.cs
示例8: AddLog
/// <summary>
/// To record a message to the log.
/// </summary>
/// <param name="receiver">Logs receiver.</param>
/// <param name="level">The level of the log message.</param>
/// <param name="getMessage">The function returns the text for <see cref="LogMessage.Message"/>.</param>
public static void AddLog(this ILogReceiver receiver, LogLevels level, Func<string> getMessage)
{
if (receiver == null)
throw new ArgumentNullException(nameof(receiver));
receiver.AddLog(new LogMessage(receiver, receiver.CurrentTime, level, getMessage));
}
开发者ID:vikewoods,项目名称:StockSharp,代码行数:13,代码来源:LoggingHelper.cs
示例9: Write
/// <summary>
/// Writes a message to the log file.
/// </summary>
/// <param name="message">The message to write.</param>
/// <param name="level">The level of severity of the log message.</param>
public void Write(string message, LogLevels level)
{
lock (_lockObject)
{
if (_logLevel < level)
{
// This message is more detailed than the user wants logged.
return;
}
if (string.IsNullOrEmpty(_filename))
{
return;
}
using (var file = new StreamWriter(_filename, true))
{
file.WriteLine(
string.Concat(
DateTime.UtcNow.ToString("M/d/yyyy HH:mm:ss"),
" Level ",
Enum.GetName(typeof(LogLevels), level),
": ",
message));
}
}
}
开发者ID:CaptainCow95,项目名称:MeshNetwork,代码行数:32,代码来源:Logger.cs
示例10: WriteLog
private static void WriteLog(LogLevels level, string message)
{
if (!Directory.Exists(LogFolder))
{
Directory.CreateDirectory(LogFolder);
}
if (level >= Settings.settingsStore.logLevel)
{
string output;
if (Settings.settingsStore.useUTCTimeInLog)
{
output = "[" + DateTime.UtcNow.ToString("HH:mm:ss") + "][" + level.ToString() + "] : " + message;
}
else
{
output = "[" + DateTime.Now.ToString("HH:mm:ss") + "][" + level.ToString() + "] : " + message;
}
Console.WriteLine(output);
ClientHandler.SendConsoleMessageToAdmins(output);
try
{
lock (logLock) {
File.AppendAllText(LogFilename, output + Environment.NewLine);
}
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Error writing to log file!, Exception: " + e);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}
开发者ID:nux17,项目名称:DarkMultiPlayer,代码行数:34,代码来源:Log.cs
示例11: LogLine
private static void LogLine(LogLevels level, string message)
{
if ((Level & level) == level)
{
LogStream.WriteLine(message);
}
}
开发者ID:jonlt,项目名称:Nugget,代码行数:7,代码来源:Log.cs
示例12: Write
/// <summary>
/// Static function used to log textual information to the console output.
/// </summary>
/// <param name="it"></param>
/// <param name="text"></param>
/// <param name="level"></param>
internal static void Write(object it, string text, LogLevels level)
{
string label = "";
if (level > Level)
return;
switch (level)
{
case LogLevels.Debug:
label = "[DEBUG] ";
break;
case LogLevels.Error:
label = "[ERROR] ";
break;
case LogLevels.Info:
break;
case LogLevels.Warning:
label = "[WARNING] ";
break;
}
if (it == null)
Console.WriteLine(label + text);
else
Console.WriteLine(it.GetType().Name + ": " + label + text);
}
开发者ID:draek,项目名称:nibiru-engine,代码行数:36,代码来源:Log.cs
示例13: WriteLog
protected override void WriteLog(LogLevels logLevel, string logRecord)
{
if (!Preferences.AutoLog) return;
// 20140317
// turning off the logger
// switch (logLevel) {
// case LogLevels.Fatal:
// Logger.Fatal(logRecord);
// break;
// case LogLevels.Error:
// Logger.Error(logRecord);
// break;
// case LogLevels.Warn:
// Logger.Warn(logRecord);
// break;
// case LogLevels.Info:
// Logger.Info(logRecord);
// break;
// case LogLevels.Debug:
// Logger.Debug(logRecord);
// break;
// case LogLevels.Trace:
// Logger.Trace(logRecord);
// break;
// }
}
开发者ID:MatkoHanus,项目名称:STUPS,代码行数:27,代码来源:CommonCmdletBase.cs
示例14: VisualLog
public static void VisualLog(LogLevels loglevel, string type, String ex)
{
// create output to console
TextWriterTraceListener console = new TextWriterTraceListener();
console.Writer = Console.Out;
Trace.Listeners.Add(console);
//output error
if (System.Diagnostics.Trace.Listeners.Count > 0)
{
Trace.Write(new TraceData(loglevel, DateTime.Now, type, ex));
}
//close streams
console.Close();
if (!ApplicationType.GetApplicationType().Equals(ApplicationType.Type.Console))
{
//messagebox
MessageBoxIcon icon = MessageBoxIcon.None;
switch (loglevel)
{
case LogLevels.Error:
icon = MessageBoxIcon.Error;
break;
case LogLevels.Warning:
icon = MessageBoxIcon.Warning;
break;
case LogLevels.Info:
icon = MessageBoxIcon.Information;
break;
}
MessageBox.Show(ex, type, MessageBoxButtons.OK, icon);
}
}
开发者ID:b1thunt3r,项目名称:bitLibCS_old,代码行数:33,代码来源:HandleLog.cs
示例15: AltLog
/// <summary>
/// Logs a message to the database logger.
/// If logger not defined, logs to the console.
/// </summary>
public static void AltLog(LogLevels eventType, int id, string message, bool forceconsole = false)
{
if (!forceconsole && Logger != null)
Logger.TraceEvent(eventType, id, message);
else
Console.WriteLine(eventType.ToString() + " " + id + " " + LMLoggers.LognLM.FlattenChars(message));
}
开发者ID:tempbottle,项目名称:INCC6,代码行数:11,代码来源:DB.cs
示例16: WriteLog
protected void WriteLog(LogLevels logLevel, System.Management.Automation.ErrorRecord errorRecord)
{
if (Preferences.AutoLog) {
this.WriteLog(logLevel, errorRecord.Exception.Message);
this.WriteLog(logLevel, "Script: '" + errorRecord.InvocationInfo.ScriptName + "', line: " + errorRecord.InvocationInfo.Line.ToString());
}
}
开发者ID:universsky,项目名称:STUPS,代码行数:8,代码来源:CommonCmdletBase.cs
示例17: LogMessage
private static void LogMessage(LogLevels level, string message)
{
if (_writer != null)
{
if ((int)_writer.LogLevel >= (int)level)
_writer.WriteLogMessage(DateTime.Now, level, message);
}
}
开发者ID:marquismark,项目名称:backbone-dotnet,代码行数:8,代码来源:Logger.cs
示例18: WriteLog
protected void WriteLog(LogLevels logLevel, ErrorRecord errorRecord)
{
//if (Preferences.AutoLog) {
WriteLog(logLevel, errorRecord.Exception.Message);
WriteLog(logLevel, "Script: '" + errorRecord.InvocationInfo.ScriptName + "', line: " + errorRecord.InvocationInfo.Line.ToString());
//}
}
开发者ID:MatkoHanus,项目名称:STUPS,代码行数:8,代码来源:CommonCmdletBase.cs
示例19: Log
/// <summary>
/// Log the message to each of the logs in the list.
/// </summary>
/// <param name="level">Level of the message.</param>
/// <param name="sMsg">Message to send.</param>
public virtual void Log(LogLevels level, string sMsg, params Object[] args)
{
// Send the message to each log
foreach(ILog log in _logs)
{
log.Log(level, sMsg, args);
}
}
开发者ID:dineshkummarc,项目名称:Eleven41.Logging,代码行数:13,代码来源:MultiLog.cs
示例20: Log
public void Log(DateTime date, LogLevels level, Dictionary<string, object> data, string sFormat, params object[] args)
{
// Send the message to each log
foreach (ILog log in _logs)
{
log.Log(date, level, data, sFormat, args);
}
}
开发者ID:eleven41,项目名称:Eleven41.Logging,代码行数:8,代码来源:MultiLog.cs
注:本文中的LogLevels类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论