本文整理汇总了C#中LogSeverity.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LogSeverity.ToString方法的具体用法?C# LogSeverity.ToString怎么用?C# LogSeverity.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogSeverity
的用法示例。
在下文中一共展示了LogSeverity.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log
/// <summary>
/// Logs the specified severity.
/// </summary>
/// <param name="severity">The severity.</param>
/// <param name="message">The message.</param>
public void Log(LogSeverity severity, string message)
{
RequiresNotNull(message);
var con = factory.OpenConnection();
con.ContinueWith(pt =>
{
var connection = pt.Result;
try
{
var cmd = connection.CreateCommand();
cmd.CommandText = "INSERT INTO Log (Id, Timestamp, Severity, Message) VALUES (NEWID(), @time, @sev, @msg)";
var timestampParameter = cmd.CreateParameter();
timestampParameter.ParameterName = "@time";
timestampParameter.Value = DateTime.Now;
cmd.Parameters.Add(timestampParameter);
var severityParameter = cmd.CreateParameter();
severityParameter.ParameterName = "@sev";
severityParameter.Value = severity.ToString();
cmd.Parameters.Add(severityParameter);
var messageParameter = cmd.CreateParameter();
messageParameter.ParameterName = "@msg";
messageParameter.Value = message;
cmd.Parameters.Add(messageParameter);
cmd.ExecuteNonQuery();
}
finally
{
connection.Dispose();
}
});
}
示例2: Log
/// <summary>
/// Log a message
/// </summary>
/// <param name="severity">The severity</param>
/// <param name="source">The source</param>
/// <param name="message">The message</param>
public void Log(LogSeverity severity, string source, string message)
{
if ((int)severity < (int)MinLogSeverity)
{
return;
}
Console.WriteLine(severity.ToString() + " " + source + " " + message);
}
示例3: Log
public void Log(string message, LogSeverity severity, Exception exception)
{
Console.WriteLine($"[bond] {severity.ToString().ToUpper()}: {message}");
if (exception != null)
{
Console.WriteLine(exception);
}
}
示例4: Log
public void Log(LogSeverity severity, string source, Exception exception)
{
Console.WriteLine(string.Format("Log : {0} - {1} - {2}", severity.ToString(), source, exception.ToString()));
if (severity == LogSeverity.Error || severity == LogSeverity.Critical)
{
Errors.Add(new KeyValuePair<string, Exception>(source, exception));
}
}
示例5: LogImpl
/// <excludedoc />
protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
{
message = String.Format("[{0}] {1}", severity.ToString().ToLowerInvariant(), message);
if (exceptionData != null)
writer.WriteException(exceptionData, message);
else
writer.WriteLine(message);
}
示例6: Log
public static void Log(string msg,LogSeverity severity=LogSeverity.Information)
{
if (ConfigurationHelper.GetLogQueueName() != null)
{
if (ConfigurationHelper.GetCurrentSeverityLevel().ToLower() == LogSeverity.Information.ToString().ToLower()
|| (severity.ToString().ToLower() == ConfigurationHelper.GetCurrentSeverityLevel().ToLower()))
{
CloudQueueMessage m = new CloudQueueMessage(msg);
queue.AddMessage(m);
}
}
}
示例7: Write
/// <summary>
/// Writes to the log.
/// </summary>
/// <param name="level">Severity of the log.</param>
/// <param name="text">Actual (formattable) text.</param>
/// <param name="args">string.Format arguments.</param>
public void Write(LogSeverity level, string text, params string[] args)
{
if (args.Length > 0) {
text = string.Format(text, args);
}
string[] split = text.Split('\n');
if (split.Length > 1) {
foreach (string part in split) {
Write(level, part);
}
return;
}
string line = string.Format(Format, new string[3] {
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
level.ToString().PadLeft(8),
text
});
LogFile.WriteLine(line);
LogEntry logEntry = new LogEntry {
Text = text,
Instance = InstanceName,
Level = level,
Line = line
};
(new Thread(() => {
foreach (Action<LogEntry> action in LogWrite) {
action.Invoke(logEntry);
}
})).Start();
}
示例8: _HandleException
private static void _HandleException (LogSeverity logLevel, string name, string message, string stackTrace, bool uncaught)
{
if (!IsInitialized) {
PrintLog (LogSeverity.Log, "It has not been initialized.");
return;
}
if (logLevel == LogSeverity.Log) {
return;
}
if ((uncaught && logLevel < _autoReportLogLevel)) {
PrintLog (LogSeverity.Log, "Not report exception for level {0}", logLevel.ToString ());
return;
}
string type = null;
string reason = null;
if (!string.IsNullOrEmpty (message)) {
try {
if ((LogSeverity.LogException == logLevel) && message.Contains ("Exception")) {
Match match = new Regex (@"^(?<errorType>\S+):\s*(?<errorMessage>.*)").Match (message);
if (match.Success) {
type = match.Groups ["errorType"].Value;
reason = match.Groups ["errorMessage"].Value.Trim ();
}
}
} catch {
}
if (string.IsNullOrEmpty (reason)) {
reason = message;
}
}
if (string.IsNullOrEmpty (name)) {
if (string.IsNullOrEmpty (type)) {
type = string.Format ("Unity{0}", logLevel.ToString ());
}
} else {
type = name;
}
_reportException (uncaught, type, reason, stackTrace);
}
示例9: LogToConsole
private static void LogToConsole(LogSeverity level, string message){
if (!_debugMode && LogSeverity.Log != level) {
if (level < LogSeverity.LogInfo) {
return;
}
}
UnityEngine.Debug.LogWarning (string.Format("[BuglyAgent] <{0}> - {1}", level.ToString(), message));
}
示例10: GetLogLevel
/// <summary>
/// Gets the log level.
/// </summary>
/// <param name="severity">The severity.</param>
/// <returns>NLog.LogLevel.</returns>
private NLog.LogLevel GetLogLevel(LogSeverity severity)
{
switch (severity)
{
case LogSeverity.Debug:
return NLog.LogLevel.Debug;
case LogSeverity.Error:
return NLog.LogLevel.Error;
case LogSeverity.Warn:
return NLog.LogLevel.Warn;
case LogSeverity.Fatal:
return NLog.LogLevel.Fatal;
case LogSeverity.Info:
return NLog.LogLevel.Info;
default:
throw new ArgumentException("Unknown LogSeverity: " + severity.ToString());
}
}
示例11: Format
public string Format(LogSeverity severity, string message)
{
return string.Format("{0} [{1}]: {2}", DateTime.Now,
severity.ToString(), message);
}
示例12: SeverityClass
/// <summary>Retrieves a CSS class for the given severity level.</summary>
/// <param name="severity">The severity of the log message.</param>
public static string SeverityClass(LogSeverity severity)
{
return string.Format("{0}_{1}", RootClass, severity.ToString());
}
示例13: FormatLogMessage
/// <summary>
/// Formats the log message.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="severity">The severity.</param>
/// <param name="messageToken">The message token.</param>
/// <param name="source">The source.</param>
/// <returns>System.String.</returns>
private static string FormatLogMessage(string message, LogSeverity severity, string messageToken = "", string source = "")
{
return string.Format(CultureInfo.InvariantCulture, "{0} | {1} | {2} | {3} | {4}{5}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), severity.ToString().ToUpper(CultureInfo.InvariantCulture), message, source, messageToken, Environment.NewLine);
}
示例14: _HandleException
private static void _HandleException(LogSeverity logLevel, string name, string message, string stackTrace, bool uncaught)
{
if (!BuglyAgent.IsInitialized)
{
BuglyAgent.PrintLog(LogSeverity.Log, "It has not been initialized.", new object[0]);
return;
}
if (logLevel == LogSeverity.Log)
{
return;
}
if (uncaught && logLevel < BuglyAgent._autoReportLogLevel)
{
BuglyAgent.PrintLog(LogSeverity.Log, "Not report exception for level {0}", new object[]
{
logLevel.ToString()
});
return;
}
string text = null;
string text2 = null;
if (!string.IsNullOrEmpty(message))
{
try
{
if (logLevel == LogSeverity.LogException && message.Contains("Exception"))
{
Match match = new Regex("^(?<errorType>\\S+):\\s*(?<errorMessage>.*)").Match(message);
if (match.Success)
{
text = match.Groups["errorType"].Value;
text2 = match.Groups["errorMessage"].Value.Trim();
}
}
}
catch
{
}
if (string.IsNullOrEmpty(text2))
{
text2 = message;
}
}
if (string.IsNullOrEmpty(name))
{
if (string.IsNullOrEmpty(text))
{
text = string.Format("Unity{0}", logLevel.ToString());
}
}
else
{
text = name;
}
BuglyAgent._reportException(uncaught, text, text2, stackTrace);
}
示例15: LogToConsole
private static void LogToConsole(LogSeverity level, string message)
{
if (!BuglyAgent._debugMode && level != LogSeverity.Log && level < LogSeverity.LogInfo)
{
return;
}
try
{
BuglyAgent.UnityAgent.Call("printLog", new object[]
{
string.Format("[BuglyAgent] <{0}> - {1}", level.ToString(), message)
});
}
catch
{
}
}