本文整理汇总了C#中ILogMessage类的典型用法代码示例。如果您正苦于以下问题:C# ILogMessage类的具体用法?C# ILogMessage怎么用?C# ILogMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILogMessage类属于命名空间,在下文中一共展示了ILogMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: From
public static AssetLogMessage From(Package package, IReference assetReference, ILogMessage logMessage, string assetPath, int line = 0, int character = 0)
{
// Transform to AssetLogMessage
var assetLogMessage = logMessage as AssetLogMessage;
if (assetLogMessage == null)
{
assetLogMessage = new AssetLogMessage(null, assetReference, logMessage.Type, AssetMessageCode.CompilationMessage, assetReference?.Location, logMessage.Text)
{
Exception = (logMessage as LogMessage)?.Exception
};
}
// Set file (and location if available)
assetLogMessage.File = assetPath;
assetLogMessage.Line = line;
assetLogMessage.Character = character;
// Generate location (if it's a Yaml exception)
var yamlException = (logMessage as LogMessage)?.Exception as YamlException;
if (yamlException != null)
{
assetLogMessage.Line = yamlException.Start.Line;
assetLogMessage.Character = yamlException.Start.Column;
// We've already got everything, no need to pollute log with stack trace of exception
assetLogMessage.Exception = null;
}
return assetLogMessage;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:29,代码来源:AssetLogMessage.cs
示例2: OnLog
protected override void OnLog(ILogMessage logMessage)
{
// Always log when debugger is attached
if (logMessage.Type < LogLevel)
{
return;
}
var color = ConsoleColor.Gray;
// set the color depending on the message log level
switch (logMessage.Type)
{
case LogMessageType.Debug:
color = ConsoleColor.DarkGray;
break;
case LogMessageType.Verbose:
color = ConsoleColor.Gray;
break;
case LogMessageType.Info:
color = ConsoleColor.Green;
break;
case LogMessageType.Warning:
color = ConsoleColor.Yellow;
break;
case LogMessageType.Error:
case LogMessageType.Fatal:
color = ConsoleColor.Red;
break;
}
logger(GetDefaultText(logMessage), color);
}
开发者ID:cg123,项目名称:xenko,代码行数:33,代码来源:LogListenerRedirectToAction.cs
示例3: OnLog
/// <inheriteddoc />
protected override void OnLog(ILogMessage msg, ref bool success)
{
var sb = new StringBuilder();
CreateString(msg, sb);
Debug.WriteLine(sb.ToString());
}
开发者ID:mkloubert,项目名称:Diagnostics.NET,代码行数:8,代码来源:DebugLogger.cs
示例4: ExportLogMessage
protected override void ExportLogMessage(IRepositoryContext context, ISession session, ILogMessage message)
{
WriteLine();
if (message.Severity == LogMessageSeverity.Verbose)
Write("{0} {1}\r\n", message.Timestamp, message.Caption.Trim());
else
{
var severity = message.Severity.ToString();
if (severity.StartsWith("Info") || severity.StartsWith("Warn"))
severity = severity.Substring(0, 4);
else
severity = severity.ToUpperInvariant();
Write("{0} {2} {1}\r\n", message.Timestamp, message.Caption.Trim(), severity);
}
if (string.IsNullOrEmpty(message.Description) == false)
{
Write("{0}\r\n", message.Description.Trim());
}
Write("Category: {0} from {1}", message.CategoryName, message.LogSystem);
if (string.IsNullOrEmpty(message.ClassName) == false)
{
Write(" {0}.{1}", message.ClassName, message.MethodName);
}
if (string.IsNullOrEmpty(message.FileName) == false)
{
Write(" in {0} ({1})", message.FileName, message.LineNumber);
}
WriteLine();
Write("Thread: {0} ({1}) for {2}\r\n", message.ThreadName, message.ThreadId, message.UserName);
IExceptionInfo currentException = message.Exception;
if (currentException != null)
{
if (Config.IncludeExceptionDetails)
{
var label = "EXCEPTION";
while (currentException != null)
{
Write("{0}: {1} - {2} from {3}\r\nStack Trace:\r\n{4}\r\n",
label, currentException.TypeName, currentException.Message.Trim(),
currentException.Source, currentException.StackTrace);
currentException = currentException.InnerException;
label = "INNER EXCEPTION";
}
}
else
{
while (currentException != null)
{
Write("{0}: {1}\r\n", currentException.TypeName, currentException.Message.Trim());
currentException = currentException.InnerException;
}
}
WriteLine();
}
}
开发者ID:jwight1976,项目名称:Loupe.Samples,代码行数:60,代码来源:DefaultLogMessageFormatter.cs
示例5: LogRaw
protected override void LogRaw(ILogMessage logMessage)
{
buildStep.Logger.Log(logMessage);
mainLogger?.Log(logMessage);
StepLogger?.Log(logMessage);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:BuildStepLogger.cs
示例6: OnLog
protected override void OnLog(ILogMessage message)
{
var serializableMessage = message as SerializableLogMessage;
if (serializableMessage == null)
{
var assetMessage = message as AssetLogMessage;
if (assetMessage != null)
{
assetMessage.Module = mainLogger.Module;
serializableMessage = new AssetSerializableLogMessage(assetMessage);
}
else
{
var logMessage = message as LogMessage;
serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null;
}
}
if (serializableMessage == null)
{
throw new ArgumentException(@"Unable to process the given log message.", "message");
}
foreach (var remoteLog in remoteLogs)
{
try
{
remoteLog.ForwardSerializableLog(serializableMessage);
}
// ReSharper disable EmptyGeneralCatchClause
catch { }
// ReSharper restore EmptyGeneralCatchClause
}
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:34,代码来源:RemoteLogForwarder.cs
示例7: Log
private void Log(ILogMessage obj)
{
if (MessageLogged != null)
{
MessageLogged(obj);
}
}
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:7,代码来源:ViewExtensionLoader.cs
示例8: CLogMessage
public CLogMessage(
IMessageSerializer messageSerializer,
DateTime timeStamp,
LogMessageCategoryEnum messageCategory,
bool isException,
bool isRootMessage,
string source,
string message,
string messageStackTrace,
string exceptionStackTrace,
ILogMessage childMessage
)
{
if (messageSerializer == null)
{
throw new ArgumentNullException("messageSerializer");
}
//childMessage allowed to be null
_messageSerializer = messageSerializer;
_timeStamp = timeStamp;
_messageCategory = messageCategory;
_isException = isException;
_isRootMessage = isRootMessage;
_source = source;
_message = message.CrLnNormalize();
_messageStackTrace = messageStackTrace.CrLnNormalize();
_exceptionStackTrace = exceptionStackTrace.CrLnNormalize();
_childMessage = childMessage;
}
开发者ID:lsoft,项目名称:XLogger,代码行数:34,代码来源:CLogMessage.cs
示例9: OnMessageLogged
private void OnMessageLogged(ILogMessage msg)
{
if (this.MessageLogged != null)
{
this.MessageLogged(msg);
}
}
开发者ID:jimb000,项目名称:Dynamo,代码行数:7,代码来源:DynamoPublishExtension.cs
示例10: OnLog
/// <inheriteddoc />
protected sealed override void OnLog(ILogMessage msg, ref bool success)
{
lock (SyncRoot)
{
base.OnLog(msg, ref success);
}
}
开发者ID:mkloubert,项目名称:Diagnostics.NET,代码行数:8,代码来源:SynchronizedLogger.cs
示例11: Add
public void Add(ILogMessage item)
{
lock(syncObj) //We can just lock because we don't lock anymore while taking. Deadlocks used to occur before, and the fix didn't work 100%, so we now don't lock on Take().
//We were able to do it lockless because we caught dipose and cancel exceptions and continued on them. There is little to no contention on syncObj anymore.
{
messageCollection.Add(item);
}
}
开发者ID:HelloKitty,项目名称:.NetLoggingServices,代码行数:8,代码来源:MessagePreparer.cs
示例12: LogRaw
protected override void LogRaw(ILogMessage logMessage)
{
TimeSpan timestamp = DateTime.Now - startTime;
lock (Messages)
{
Messages.Add(new Message(timestamp.Ticks, logMessage));
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:TimestampLocalLogger.cs
示例13: OnLog
protected override void OnLog(ILogMessage logMessage)
{
Debug.WriteLine(GetDefaultText(logMessage));
var exceptionMsg = GetExceptionText(logMessage);
if (!string.IsNullOrEmpty(exceptionMsg))
{
Debug.WriteLine(exceptionMsg);
}
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:9,代码来源:DebugLogListener.cs
示例14: OnLog
protected override void OnLog(ILogMessage message)
{
if (!activeRemoteLogs)
return;
var serializableMessage = message as SerializableLogMessage;
if (serializableMessage == null)
{
var assetMessage = message as AssetLogMessage;
if (assetMessage != null)
{
assetMessage.Module = mainLogger.Module;
serializableMessage = new AssetSerializableLogMessage(assetMessage);
}
else
{
var logMessage = message as LogMessage;
serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null;
}
}
if (serializableMessage == null)
{
throw new ArgumentException(@"Unable to process the given log message.", "message");
}
for (int i = 0; i < remoteLogs.Count; i++)
{
var remoteLog = remoteLogs[i];
try
{
remoteLog?.ForwardSerializableLog(serializableMessage);
}
// ReSharper disable EmptyGeneralCatchClause
catch
{
// Communication failed, let's null it out so that we don't try again
remoteLogs[i] = null;
TryCloseChannel(remoteLog);
// Check if we still need to log anything
var newActiveRemoteLogs = false;
for (int j = 0; j < remoteLogs.Count; j++)
{
if (remoteLogs[j] != null)
{
newActiveRemoteLogs = true;
break;
}
}
activeRemoteLogs = newActiveRemoteLogs;
}
// ReSharper restore EmptyGeneralCatchClause
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:56,代码来源:RemoteLogForwarder.cs
示例15: SendMessage
}// end constructeur
/// <summary>
/// Enregistre Le message dans un fichier de Log
/// </summary>
/// <param name="MonLevel">Niveau de criticité</param>
/// <param name="MonMessage">Message à enresgitrer</param>
/// <param name="MonContexte">Contexte d'exécution</param>
public override void SendMessage(LogLevel MonLevel, ILogMessage MonMessage, ILogContexte MonContexte)
{
DBCnx curCon = DbCnxManager.CreateConnectionFromConnectingString(ConnectionString);
curCon.SQL_Execute("PR_LOG_MESSAGE", "@LOG_LEVEL", MonLevel, "@Origin", MonContexte.Origin, "@scope", MonContexte.Scope, "@loguser", MonContexte.CurrentUser
, "@domaine", MonMessage.Domaine, "@MESSAGE_NUMBER", MonMessage.NumMessage, "@LOG_MESSAGE", MonMessage.TexteMessage, "@OTHERSINFOS", JsonConvert.SerializeObject(MonContexte.InfosComplementaires));
curCon.Dispose();
}
开发者ID:gerald13,项目名称:NSLog,代码行数:21,代码来源:DBAppender.cs
示例16: LogRaw
protected override void LogRaw(ILogMessage logMessage)
{
base.LogRaw(logMessage);
if (loggerToForward != null)
{
lock (loggerToForward)
{
loggerToForward.Log(logMessage);
}
}
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:11,代码来源:ForwardingLoggerResult.cs
示例17: FormatLog
private static string FormatLog(ILogMessage message)
{
//$filename($row,$column): $error_type $error_code: $error_message
//C:\Code\Paradox\sources\assets\SiliconStudio.Assets.CompilerApp\PackageBuilder.cs(89,13,89,70): warning CS1717: Assignment made to same variable; did you mean to assign something else?
var builder = new StringBuilder();
builder.Append(message.Module);
builder.Append(": ");
builder.Append(message.Type.ToString().ToLowerInvariant()).Append(" ");
builder.Append((clock.ElapsedMilliseconds * 0.001).ToString("0.000"));
builder.Append("s: ");
builder.Append(message.Text);
return builder.ToString();
}
开发者ID:robterrell,项目名称:paradox,代码行数:13,代码来源:Program.cs
示例18: GetFingerprint
/// <summary>
/// Return a unique fingerprint string for this message (presumably an error)
/// </summary>
/// <remarks>
/// <para>This is an important method. Think of the fingerprint like a hashcode.
/// All instances of the same logical error should have the same fingerprint.
/// Each unique error should have a unique fingerprint.
/// </para>
/// <para>This implementation makes the reasonably good assumption that a fingerprint
/// should be based on product + application + caption + classname + category.</para>
/// <para>There are three main weaknesses to this approach:</para>
/// <para>1. If the caption varies across instances, each will be assigned
/// a unique fingerprint. To minimize this, make sure to put all dynamic fields such as
/// parameter values in the message description, not the caption.</para>
/// <para>2. Localization. If the caption is localized, each language will result
/// in a unique fingerprint.</para>
/// <para>3. If the caption is too generic (ex., null reference exception) different
/// errors might be erroneously grouped together.</para>
/// </remarks>
private static string GetFingerprint(ILogMessage message)
{
ISessionSummary summary = message.Session.Summary;
StringBuilder builder = new StringBuilder();
builder.AppendFormat("Loupe Error Fingerprint:\r\n");
builder.AppendFormat("Product: {0}\r\n", summary.Product);
builder.AppendFormat("Application: {0}\r\n", summary.Application);
builder.AppendFormat("Caption: {0}\r\n", message.Caption);
builder.AppendFormat("ClassName: {0}\r\n", message.ClassName);
builder.AppendFormat("Category: {0}\r\n", message.CategoryName);
string hash = GetHash(builder.ToString());
return hash;
}
开发者ID:jwight1976,项目名称:Loupe.Samples,代码行数:33,代码来源:ErrorInfo.cs
示例19: OnLog
/// <inheriteddoc />
protected override void OnLog(ILogMessage msg, ref bool success)
{
var handler = MessageReceived;
if (handler == null)
{
return;
}
var e = new LogEventArgs(msg)
{
Handled = true,
};
handler(this, e);
success = e.Handled;
}
开发者ID:mkloubert,项目名称:Diagnostics.NET,代码行数:17,代码来源:EventLogger.cs
示例20: LogRaw
protected override void LogRaw(ILogMessage logMessage)
{
buildStep.Logger.Log(logMessage);
if (mainLogger != null)
{
mainLogger.Log(logMessage);
}
if (StepLogger != null)
{
lock (StepLogger)
{
StepLogger.Log(logMessage);
}
}
}
开发者ID:cg123,项目名称:xenko,代码行数:16,代码来源:BuildStepLogger.cs
注:本文中的ILogMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论