using Serilog; using Serilog.Events; using ZB.MOM.WW.OtOpcUa.Core.Scripting; namespace ZB.MOM.WW.OtOpcUa.Host.Logging; /// /// Composes the root script — the single pipeline every /// per-script logger derives from. Fans each script log event out to three destinations: /// a dedicated rolling scripts-*.log file, the main server log (via /// , mirroring Error-or-higher events at Warning), and /// the cluster script-logs DPS topic (via ) so the /// live Script-log Admin UI page can tail script output. /// public static class ScriptRootLoggerFactory { /// /// Builds the composed root script logger. /// /// /// The publisher the topic sink forwards entries to (the DPS publisher in production). /// /// /// Path template for the rolling scripts-*.log file sink (e.g. logs/scripts-.log). /// /// /// Minimum level for events forwarded to the script-logs topic; lower-level events /// still land in the file sink but are not pushed onto the cluster bus. /// /// The composed root script logger. public static Serilog.ILogger Build(IScriptLogPublisher publisher, string filePath, LogEventLevel topicMinLevel) => new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.File(filePath, rollingInterval: RollingInterval.Day) .WriteTo.Sink(new ScriptLogCompanionSink(Serilog.Log.Logger)) .WriteTo.Sink(new ScriptLogTopicSink(publisher, topicMinLevel)) .CreateLogger(); }