本文整理汇总了C#中MessageLevel类的典型用法代码示例。如果您正苦于以下问题:C# MessageLevel类的具体用法?C# MessageLevel怎么用?C# MessageLevel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageLevel类属于命名空间,在下文中一共展示了MessageLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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;
}
}
示例3: LogMessageAttributes
public LogMessageAttributes(Stream stream)
{
Classification = (MessageClass)stream.ReadByte();
Level = (MessageLevel)stream.ReadByte();
MessageSuppression = (MessageSuppression)stream.ReadByte();
Flags = (MessageFlags)stream.ReadByte();
}
示例4: SetNewMessage
public void SetNewMessage(MessageLevel Level,string Message,string CodeIndex)
{
MessageItem newItem = new MessageItem();
newItem.CodeIndex = CodeIndex;
newItem.Message = Message;
newItem.SelectedMessageLevel = Level;
}
示例5: Message
public Message(MessageLevel level, int code, string phrase, params string[] phraseTokens)
{
Level = level;
Code = code;
Phrase = phrase;
Tokens = phraseTokens;
}
示例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);
}
示例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();
}
示例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;
}
});
}
示例9: Log
public void Log(string message, MessageLevel messageLevel)
{
if(EventLog != null)
{
EventLog(message, messageLevel);
}
}
示例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;
}
示例11: PackageOperationMessageLoggedEventArgs
public PackageOperationMessageLoggedEventArgs(
MessageLevel level,
string message,
params object[] args)
{
this.Message = new PackageOperationMessage(level, message, args);
}
示例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;
}
示例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();
}
示例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);
}
}
示例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
}
}