本文整理汇总了C#中MessageLevel类的典型用法代码示例。如果您正苦于以下问题:C# MessageLevel类的具体用法?C# MessageLevel怎么用?C# MessageLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageLevel类属于命名空间,在下文中一共展示了MessageLevel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Log
public void Log(MessageLevel level, string message, params object[] args)
{
var calleeType = new StackTrace().GetFrame(1).GetMethod().DeclaringType ?? GetType();
var logger = LogManager.GetLogger(calleeType);
Action<Action<FormatMessageHandler>> logMethod;
switch (level)
{
case MessageLevel.Debug:
logMethod = logger.Debug;
break;
case MessageLevel.Info:
logMethod = logger.Info;
break;
case MessageLevel.Error:
logMethod = logger.Error;
break;
case MessageLevel.Warning:
default:
logMethod = logger.Warn;
break;
}
logMethod(m => m(message, args));
}
开发者ID:battenworks,项目名称:NuGet.Lucene,代码行数:27,代码来源:NuGetCommonLoggingAdapter.cs
示例2: Log
public void Log(MessageLevel level, string message, params object[] args)
{
if (args.Length > 0)
{
message = string.Format(CultureInfo.CurrentCulture, message, args);
}
switch (level)
{
case MessageLevel.Debug:
_logger.LogDebug(message);
break;
case MessageLevel.Info:
_logger.LogMinimal(message);
break;
case MessageLevel.Warning:
_logger.LogWarning(message);
break;
case MessageLevel.Error:
_logger.LogError(message);
break;
}
}
开发者ID:InfinniPlatform,项目名称:Infinni.Node,代码行数:26,代码来源:NuGetLoggerProjectContext.cs
示例3: LogMessageAttributes
public LogMessageAttributes(Stream stream)
{
Classification = (MessageClass)stream.ReadByte();
Level = (MessageLevel)stream.ReadByte();
MessageSuppression = (MessageSuppression)stream.ReadByte();
Flags = (MessageFlags)stream.ReadByte();
}
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:7,代码来源:LogMessageAttributes.cs
示例4: SetNewMessage
public void SetNewMessage(MessageLevel Level,string Message,string CodeIndex)
{
MessageItem newItem = new MessageItem();
newItem.CodeIndex = CodeIndex;
newItem.Message = Message;
newItem.SelectedMessageLevel = Level;
}
开发者ID:newsike,项目名称:Buffalo-Famework,代码行数:7,代码来源:MessageServices.cs
示例5: Message
public Message(MessageLevel level, int code, string phrase, params string[] phraseTokens)
{
Level = level;
Code = code;
Phrase = phrase;
Tokens = phraseTokens;
}
开发者ID:benpriebe,项目名称:ServerRI,代码行数:7,代码来源:Message.cs
示例6: Write
public void Write(MessageLevel level, Exception ex)
{
if (this.MessageReceived == null) return;
MessageEventArgs msgArgs = new MessageEventArgs(level, ex.GetAllMessage());
this.MessageReceived(null, msgArgs);
}
开发者ID:piaolingzxh,项目名称:Justin,代码行数:7,代码来源:MessageSvc.cs
示例7: SendMessage
public static void SendMessage(this StreamWriter writer, ReportType type, MessageLevel level, string message)
{
var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
var report = "{0}|{1}|{2}".FormatWith(type, level, encodedMessage);
writer.WriteLine(report);
writer.Flush();
}
开发者ID:GlennHaworth,项目名称:Unicorn,代码行数:7,代码来源:StreamWriterExtensions.cs
示例8: ShowMessage
public Task ShowMessage(string message, string title, MessageLevel level)
{
//TODO:Need to implement tooltip and message logging in case for none
return Task.Factory.StartNew(() =>
{
switch (this._messageTarget)
{
case MessageTarget.MessageBox:
if (this.InvokeRequired)
{
this.Invoke(new Action(() =>
{
MessageBox.Show(message, title, MessageBoxButtons.OK, FrmMain.GetIcon(level));
}));
}
else
MessageBox.Show(message, title, MessageBoxButtons.OK, FrmMain.GetIcon(level));
break;
case MessageTarget.ToolTip:
break;
case MessageTarget.None:
break;
default:
break;
}
});
}
开发者ID:Liano,项目名称:Samaa,代码行数:28,代码来源:FrmMain.cs
示例9: Log
public void Log(string message, MessageLevel messageLevel)
{
if(EventLog != null)
{
EventLog(message, messageLevel);
}
}
开发者ID:avatar29A,项目名称:GlobalSat-DataLogger-DGX,代码行数:7,代码来源:SimpleLogger.cs
示例10: WixGenericMessageEventArgs
/// <summary>
/// Creates a new generc message event arg.
/// </summary>
/// <param name="sourceLineNumbers">Source line numbers for the message.</param>
/// <param name="id">Id for the message.</param>
/// <param name="level">Level for the message.</param>
/// <param name="format">Format message for arguments.</param>
/// <param name="messageArgs">Arguments for the format string.</param>
public WixGenericMessageEventArgs(SourceLineNumberCollection sourceLineNumbers, int id, MessageLevel level, string format, params object[] messageArgs)
: base(sourceLineNumbers, id, format, messageArgs)
{
this.resourceManager = new GenericResourceManager();
this.Level = level;
}
开发者ID:zooba,项目名称:wix3,代码行数:15,代码来源:WixGenericMessageEventArgs.cs
示例11: PackageOperationMessageLoggedEventArgs
public PackageOperationMessageLoggedEventArgs(
MessageLevel level,
string message,
params object[] args)
{
this.Message = new PackageOperationMessage(level, message, args);
}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:7,代码来源:PackageOperationMessageLoggedEventArgs.cs
示例12: LogMessage
/// <summary>
/// Constructor.
/// </summary>
/// <param name="message"><c>String</c> that specifies the name of the <c>LogMessage</c>.</param>
/// <param name="level"><c>MessageLevel</c> that specifies the level of the <c>LogMessage</c>.</param>
/// <returns><c>LogMessage</c> object</returns>
public LogMessage(
String message,
MessageLevel level)
{
this.Message = message;
this.Level = level;
}
开发者ID:rogue-bit,项目名称:Triton-Framework,代码行数:13,代码来源:LogMessage.cs
示例13: SendMessage
private void SendMessage(ReportType type, MessageLevel level, string message)
{
var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
var report = "{0}|{1}|{2}".FormatWith(type, level, encodedMessage);
_output.WriteLine(report);
_output.Flush();
}
开发者ID:ramnkl,项目名称:Unicorn,代码行数:7,代码来源:RemoteLogger.cs
示例14: OnPackageOperationMessageLogged
public void OnPackageOperationMessageLogged(MessageLevel level, string message, params object[] args)
{
if (PackageOperationMessageLogged != null) {
var eventArgs = new PackageOperationMessageLoggedEventArgs(level, message, args);
PackageOperationMessageLogged(this, eventArgs);
}
}
开发者ID:eswarpr,项目名称:monodevelop-nuget-addin,代码行数:7,代码来源:PackageManagementEvents.cs
示例15: Post
public IObservable<bool> Post(string url, string message, MessageLevel level = MessageLevel.Info)
{
// Create an HttpClient and send content payload
using (var httpClient = HttpClient)
{
#if __IOS__ || __ANDROID__ || NET45
var content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"message", message},
{"level", level.ToString().ToLower()}
});
#endif
#if NETFX_CORE
var content = new HttpFormUrlEncodedContent(new Dictionary<string, string>
{
{"message", message},
{"level", level.ToString().ToLower()}
});
#endif
#if __IOS__ || __ANDROID__ || NET45
return httpClient.PostAsync(new Uri(url), content)
.ToObservable()
.Select(response => response.IsSuccessStatusCode);
#endif
#if NETFX_CORE
return httpClient.PostAsync(new Uri(url), content)
.AsTask()
.ToObservable()
.Select(response => response.IsSuccessStatusCode);
#endif
}
}
开发者ID:gep13,项目名称:gitter-api-pcl,代码行数:33,代码来源:ReactiveWebhookService.cs
示例16: LastChanceLog
/// <summary>
/// Last chance logging if primary logging sink fails. Usually used on application boot strapping. Log file will be located in
/// either the file location of Log.LastChangeLogFile or in the default folder of the running application. NOTE: Bypasses
/// any configured log provider (log4Net, NLog, TraceLog, etc) and writes directly to text file. Use with extreme care and is
/// not configured for high performance.
/// </summary>
/// <param name="logLevel">Level this message will be logged at</param>
/// <param name="message">Text of message</param>
/// <param name="args">Arguments to supply to message text (if any)</param>
public static void LastChanceLog(MessageLevel logLevel, string message, params object[] args)
{
string logMessage = "";
try
{
_lastChanceLock.EnterWriteLock();
if (CoreConfig.Log.IsLastChanceLogEnabled == false) return; // last chance logging not enabled
logMessage = TextUtils.StringFormat("{0:yyyy-MM-dd HH:mm:ss.fff} {1} {2}", DateTime.Now, logLevel.ToString().ToUpper(), TextUtils.StringFormat(message, args));
File.AppendAllText(CoreConfig.Log.LastChanceLogFile, logMessage + Environment.NewLine);
}
catch (Exception ex)
{
try // write to event log if unable to log to last chance file. This is really the last chance of the last chance!
{
EventLog.WriteEntry("Application Error", string.Format(logMessage, args), EventLogEntryType.Error);
EventLog.WriteEntry("Application Error", string.Format(ex.ToString()), EventLogEntryType.Error);
}
catch (Exception ex2) //couldn't write log to last chance log file or event viewer so swallow exception
{
System.Diagnostics.Debug.WriteLine(string.Format("Error in LastChanceLog: {0}{1}{2}", ex2.Message, Environment.NewLine, logMessage));
}
}
finally
{
_lastChanceLock.ExitWriteLock();
}
}
开发者ID:drio4321,项目名称:ScrimpNet.Core,代码行数:39,代码来源:Log.LastChance.cs
示例17: Error
public Error(MessageLevel category, string message, int code, Node node)
: this()
{
Node = node;
Message = message;
Code = code;
Category = category;
}
开发者ID:palad1,项目名称:ceylon-dotnet,代码行数:8,代码来源:Error.cs
示例18: AddMessage
public void AddMessage(MessageLevel level, string text, params object[] args)
{
var formattedText = args.Length > 0 ?
string.Format(text, args) :
text;
_callback.Invoke(new Message(formattedText, level));
}
开发者ID:rosaliafx,项目名称:Rosalia,代码行数:8,代码来源:LogHelper.cs
示例19: SendMessage
private void SendMessage(ReportType type, MessageLevel level, string message)
{
var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
var report = $"{type}|{level}|{encodedMessage}";
_output.WriteLine(report);
_output.Flush();
}
开发者ID:BerserkerDotNet,项目名称:Unicorn.VisualStudio,代码行数:8,代码来源:ProgressReporter.cs
示例20: StatusReport
private StatusReport(string text, MessageLevel level, OperationType type, ReportType reportType)
{
Message = text;
MessageLevel = level;
OperationType = type;
MessageTime = DateTime.Now;
ReportType = reportType;
}
开发者ID:BerserkerDotNet,项目名称:Unicorn.VisualStudio,代码行数:8,代码来源:StatusReport.cs
注:本文中的MessageLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论