You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System; using System.Collections.Generic;
namespace Apewer.Web {
/// <summary></summary>
public static class CronLog {
private static object Locker = new object();
/// <summary>合并 Log 内容。</summary>
public static string Merge(params object[] content) { var text = TextUtility.Join(" | ", content) ?? ""; text = "Cron | " + text; return text; }
/// <summary>合并 Log 内容。</summary>
public static string Merge(Exception exception) { try { return Merge("Exception", exception.GetType().FullName, exception.Message); } catch { return Merge("Exception", "无法记录日志的异常。"); } }
/// <summary>调用 Log 处理程序。</summary>
public static void Invoke(Action<string> action, params object[] content) { RuntimeUtility.InBackground(() => { var text = Merge(content); lock (Locker) { try { if (action == null) Console(text); else action(text); } catch { } } }); }
/// <summary>向控制台写入文本的 Log 处理程序。</summary>
public static void Console(string text) => Logger.Console.Text(nameof (CronLog), text);
}
}
|