本文整理汇总了C#中ILogger.Write方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.Write方法的具体用法?C# ILogger.Write怎么用?C# ILogger.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Invoke
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger)
{
var channelName = message.Parameters[0];
var mode = message.Parameters[1];
var nickName = message.Parameters[2];
var userInfo = ircClient.Channels[channelName].GetUser(nickName);
if (userInfo == null)
{
userInfo = ircClient.UserService.GetOrCreateUser(nickName, channelName);
logger.Write($"Detected new user by MODE {nickName} on channel {channelName}");
}
if (mode.Equals("+o") && !userInfo.IsModerator)
{
logger.Write($"Adding moderator status for {nickName} on {channelName}");
userInfo.IsModerator = true;
ircClient.Channels[channelName].UpdateUser(userInfo);
}
else if (mode.Equals("-o") && userInfo.IsModerator)
{
logger.Write($"Removing moderator status for {nickName} on {channelName}");
userInfo.IsModerator = false;
ircClient.Channels[channelName].UpdateUser(userInfo);
}
else
{
logger.Write($"Mode {mode} sat on user {nickName} on {channelName}");
}
}
示例2: ExportToLog
public override void ExportToLog(Summary summary, ILogger logger)
{
logger.WriteLine("<!DOCTYPE html>");
logger.WriteLine("<html lang='en'>");
logger.WriteLine("<head>");
logger.WriteLine("<meta charset='utf-8' />");
logger.WriteLine("<title>" + summary.Title + "</title>");
logger.WriteLine(CssDefinition);
logger.WriteLine("</head>");
logger.WriteLine("<body>");
logger.Write("<pre><code>");
logger.WriteLine();
foreach (var infoLine in HostEnvironmentInfo.GetCurrent().ToFormattedString())
{
logger.WriteLine(infoLine);
}
logger.WriteLine(summary.JobRuntimes);
logger.Write("</code></pre>");
logger.WriteLine();
PrintTable(summary.Table, logger);
logger.WriteLine("</body>");
logger.WriteLine("</html>");
}
示例3: PrintTable
private void PrintTable(SummaryTable table, ILogger logger)
{
if (table.FullContent.Length == 0)
{
logger.WriteLineError("<pre>There are no benchmarks found</pre>");
return;
}
logger.Write("<pre><code>");
table.PrintCommonColumns(logger);
logger.WriteLine("</code></pre>");
logger.WriteLine();
logger.WriteLine("<table>");
logger.Write("<tr>");
table.PrintLine(table.FullHeader, logger, "<th>", "</th>");
logger.Write("</tr>");
foreach (var line in table.FullContent)
{
logger.Write("<tr>");
table.PrintLine(line, logger, "<td>", "</td>");
logger.Write("</tr>");
}
logger.WriteLine("</table>");
}
示例4: ExportToLog
public override void ExportToLog(Summary summary, ILogger logger)
{
logger.Write("<pre><code>");
logger.WriteLine();
foreach (var infoLine in HostEnvironmentInfo.GetCurrent().ToFormattedString())
{
logger.WriteLine(infoLine);
}
logger.Write("</code></pre>");
logger.WriteLine();
PrintTable(summary.Table, logger);
}
示例5: Invoke
public List<string> Commands = > new List<string> { "376", "CAP" }; //376 = End of MOTD
#endregion Fields
#region Methods
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger)
{
if (message.Command.Equals("376"))
{
logger.Write("Connected and registered with the server");
//Tell the twitch IRC server that we want to receive join and parts
logger.Write("Attemting to register to receive JOIN/PART messages");
ircClient.SendRawMessage("CAP REQ :twitch.tv/membership");
}
else if (message.Command.Equals("CAP") && message.Parameters.Contains("ACK"))
{
logger.Write("We are now registered to receive JOIN/PART messages");
}
}
示例6: PrintTable
private void PrintTable(SummaryTable table, ILogger logger)
{
if (table.FullContent.Length == 0)
{
logger.WriteLineError("There are no benchmarks found ");
logger.NewLine();
return;
}
table.PrintCommonColumns(logger);
logger.NewLine();
if (useCodeBlocks)
{
logger.Write("```");
logger.NewLine();
}
table.PrintLine(table.FullHeader, logger, "", " |");
logger.NewLine();
logger.WriteLineStatistic(string.Join("", table.Columns.Where(c => c.NeedToShow).Select(c => new string('-', c.Width) + " |")));
foreach (var line in table.FullContent)
{
table.PrintLine(line, logger, "", " |");
logger.NewLine();
}
}
示例7: Invoke
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger)
{
if (message.Command.Equals("376") && !_isInitialized) //We use this to initialize the plugin. This should only happen once.
{
_ircClient = ircClient;
_logger = logger;
//Subscribe to when the stream startes/ends events
_ircClient.TwitchService.OnStreamOnline += TwitchService_OnStreamOnline;
_ircClient.TwitchService.OnStreamOffline += TwitchService_OnStreamOffline;
_timer.AutoReset = true;
_timer.Interval = 60000;
_timer.Elapsed += _timer_Elapsed;
_timer.Enabled = true;
_dataFolder = PluginHelper.GetPluginDataFolder(this);
_database = new SQLiteConnection(new SQLitePlatformWin32(), Path.Combine(_dataFolder, "CurrencyPlugin.db"));
_database.CreateTable<CurrencyUserModel>();
//This is for debugging
//_watchedChannelsList.Add("#unseriouspid");
//_onlineChannelsList.Add("#unseriouspid");
_logger.Write($"{GetType().Name} Initialized.");
_isInitialized = true;
}
else if (message.Command.Equals("PRIVMSG") &&
_isInitialized &&
_watchedChannelsList.Contains(message.GetChannelName()))
{
var userCommand = message.Trailing.Split(' ')[0].ToLower().TrimStart();
var nickName = message.GetSender();
var channelName = message.GetChannelName();
switch (userCommand)
{
case "!points":
if (IsUserCommandOnCooldown(userCommand, nickName, channelName)) return;
DisplayPoints(nickName, channelName);
CooldownUserCommand(userCommand, nickName, channelName);
break;
case "!gamble":
if (IsUserCommandOnCooldown(userCommand, nickName, channelName)) return;
DoGamble(message);
CooldownUserCommand(userCommand, nickName, channelName);
break;
case "!bonus":
DoAddBonus(message);
break;
case "!bonusall":
DoAddBonusAll(message);
break;
}
}
}
示例8: Register
public Register(IBasket basket, IDisplay display, IScanner scanner)
{
logger = LoggerFactory.GetLogger();
this.basket = basket;
this.display = display;
this.scanner = scanner;
basket.OnAdd += display.AddProduct;
basket.AddSuccess += scanner.FlashLed;
basket.AddFail += scanner.FlashLed;
basket.OnUpdate += display.UpdateProduct;
basket.OnRemove += display.RemoveProduct;
basket.OnUpdateTotalCost += display.UpdateTotalCost;
basket.OnUpdateProductCount += display.UpdateProductCount;
display.OnStartScan += scanner.Start;
display.OnStopScan += scanner.Stop;
display.OnClear += basket.Clear;
scanner.OnRead += new OnReadHandler(scanner_OnRead);
logger.Write("Register", LogLevel.INFO, "Register initialized");
display.Display();
}
示例9: Player
public Player(
ILogger Logger_,
IFolderService FolderService_,
ILocalization loc_,
bool starttimer = true
//,ISystemMessagePlatformSpecific isystemMessage_
)
{
Logger = Logger_;
FolderService = FolderService_;
Loc = loc_;
//SystemMessage = isystemMessage_;
Logger.Write(this, LogMsgType.DeepTrace, "Player has been constructed");
PreviousPosition = 0;
ClearTargetPosition();
if (starttimer)
{
timer = new TimerExt(20);
//timer.Enabled = true;
timer.Elapsed += timer_Elapsed;
timer.AutoReset = false;
//timer.Start();
}
}
示例10: ShoppingList
public ShoppingList()
{
logger = LoggerFactory.GetLogger();
products = new Dictionary<Product, int>();
logger.Write("Register/ShoppingList", LogLevel.INFO, "ShopplingList initialized");
}
示例11: OperationContext
/// <summary>
/// Initializes a new instance of the <see cref="OperationContext" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="identifier">The identifier used for the operation. If not specified, a random guid will be used.</param>
/// <param name="description">A description for the operation.</param>
/// <param name="level">The level used to write the operation details to the logger. By default this is the information level.</param>
/// <param name="warnIfExceeds">Specifies a limit, if it takes more than this limit, the level will be set to warning. By default this is not used.</param>
/// <param name="autoSucceedOnExit">Specifies whether or not the operation should be marked with an outcome of <see cref="OperationOutcome.Success"/> if it completes without exception.</param>
/// <param name="autoFailOnException">Specifies whether or not the operation should be marked with an outcome of <see cref="OperationOutcome.Fail"/> if an exception is detected.</param>
/// <param name="propertyBag">A colletion of additional properties to associate with the current operation. This is typically an anonymous type.</param>
internal OperationContext(ILogger logger,
LogEventLevel level,
TimeSpan? warnIfExceeds,
object identifier,
string description,
bool autoSucceedOnExit,
bool autoFailOnException,
object propertyBag)
{
_logger = logger;
_level = level;
_warnIfExceeds = warnIfExceeds;
_identifier = identifier;
_description = description;
_autoSucceedOnExit = autoSucceedOnExit;
_autoFailOnException = autoFailOnException;
_operationContextBookmark = OperationLogContext.PushOperationId(identifier);
if (propertyBag != null)
{
// Save the first contextual property that we set. We then dispose of this bookmark, reverting the stack to what it was previously
_contextualPropertiesBookmark = PushProperties(propertyBag);
}
_logger.Write(_level, BeginOperationMessage, _identifier, _description);
_sw = Stopwatch.StartNew();
}
示例12: DisplayResults
public void DisplayResults(ILogger outputLogger)
{
if (logger.CapturedOutput.Count > 0)
outputLogger.WriteLineHeader(new string('-', 20));
foreach (var line in logger.CapturedOutput)
outputLogger.Write(line.Kind, line.Text);
}
示例13: Invoke
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger)
{
var channelName = message.GetChannelName();
var nickName = message.GetSender();
if (MessageHelper.IsMessageFromMe(message, ircClient.Credentials))
{
logger.Write($"We left channel {channelName}");
ircClient.Channels.RemoveIfExists(channelName);
}
else
{
logger.Write($"PART {nickName} from channel {channelName}");
var user = ircClient.UserService.GetOrCreateUser(nickName, channelName);
ircClient.Channels[channelName].RemoveUser(user);
}
}
示例14: ExportToLog
public override void ExportToLog(Summary summary, ILogger logger)
{
foreach (var line in summary.Table.FullContentWithHeader)
{
for (int i = 0; i < line.Length;)
{
logger.Write(CsvHelper.Escape(line[i]));
if (++i < line.Length)
{
logger.Write(separator);
}
}
logger.WriteLine();
}
}
示例15: Gui
public Gui()
{
logger = LoggerFactory.GetLogger();
scanning = false;
InitializeComponent();
logger.Write("Register/Gui", LogLevel.INFO, "Gui initialized");
}