private void LogExceptions(Serilog.ILogger logger) { if (LogUnhandledExceptions) { AppDomain.CurrentDomain.UnhandledException += (s, e) => { try { logger.Fatal("{@Sender} {@UnhandledException}", s, e); } catch (Exception ex) { logger.Fatal("Exception thrown while showing exception: {@Exception}", ex); } }; } }
public SerilogLogger(Serilog.ILogger logger) { log = logger; }
public Logger(Serilog.ILogger logger) { _logger = logger; }
// RegisterOpenCardUserInfoCommand命令的处理程序 // 整个命令处理程序的核心都在这里 // 不仅包括命令验证的收集,持久化,还有领域事件和通知的添加 public async Task <Unit> Handle(RegisterSerilogCommand message, CancellationToken cancellationToken) { // 命令验证 if (!message.IsValid()) { await NotifyValidationErrorsAsync(message); // 错误信息收集 return(await Task.FromResult(new Unit())); // 返回,结束当前线程 } // 实例化领域模型,这里才真正的用到了领域模型 // 注意这里是通过构造函数方法实现 var customer = new Serilog(message.Id, message.Message, message.Level, message.TimeStamp, message.Exception, message.LogEvent, message.Remarks, message.IsDeleted, message.IsEnable, message.CreateTime, message.CreateUserId, message.ModifyUserId); // 持久化 await _CommandRepository.AddAsync(customer); // 统一提交 if (await CommitAsync()) { //通过领域事件发布 成功 通知 await Bus.RaiseEvent(new DomainNotification(DomainHandlerType.Register, DomainNotificationType.Success, "", $"{typeof(Serilog).Name} 登记成功")); } return(await Task.FromResult(new Unit())); }
public SerilogLog(Serilog.ILogger logger, bool demoteDebug = false) { if (logger == null) throw new ArgumentNullException(nameof(logger)); _logger = logger; _demoteDebug = demoteDebug; }
/// <summary> /// Add Serilog to the logging pipeline. /// </summary> /// <param name="factory">The logger factory to configure.</param> /// <param name="logger">The Serilog logger; if not supplied, the static <see cref="Serilog.Log"/> will be used.</param> /// <returns>The logger factory.</returns> public static ILoggerFactory AddSerilog( this ILoggerFactory factory, Serilog.ILogger logger = null) { if (factory == null) throw new ArgumentNullException("factory"); factory.AddProvider(new SerilogLoggerProvider(logger)); return factory; }
public static void AddSerilog(Serilog.ILogger logger = null) { var factory = GetFactory(); lock(s_syncLock) { Serilog.SerilogLoggerFactoryExtensions.AddSerilog(factory, logger); } }
public async Task ExcludesGloballyIgnoredProject(Project p) { _ruleSet.IgnoreGlobally.Projects = new[] { p.Name }; Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(new[] { p }); await _sut.Process(); Serilog.Verify(l => l.Verbose("Skipping project {@project}", p.Name), Times.Once); Harbor.Verify(h => h.GetRepositories(It.IsAny <int>()), Times.Never); }
public async Task RuleExcludesTag(Tag t) { _fixture.Inject(new Regex(".*")); _ruleSet.Rules.Add(_fixture.Build <Rule>().WithAutoProperties().With(r => r.Ignore, new[] { t.Name }).Create()); Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(new[] { t }); await _sut.Process(); Serilog.Verify(l => l.Information("Tag {repo}:{name} skipped because it was found in an ignore list that applies to {repo}", t.Repository, t.Name, _repository.Name), Times.Once); Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public async Task ExcludesGloballyIgnoredRepos(Project p, Repository r) { _ruleSet.IgnoreGlobally.Repos = new[] { r.Name }; Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(new[] { p }); Harbor.Setup(h => h.GetRepositories(It.IsAny <int>())).ReturnsAsync(new[] { r }); await _sut.Process(); Serilog.Verify(l => l.Verbose("Skipping repository {@repository}", r), Times.Once); Harbor.Verify(h => h.GetTags(It.IsAny <string>()), Times.Never); }
public async Task ExcludesGloballyIgnoredTags(Project p, Repository r, Tag t) { _ruleSet.IgnoreGlobally.Tags = new[] { t.Name }; Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(new[] { p }); Harbor.Setup(h => h.GetRepositories(It.IsAny <int>())).ReturnsAsync(new[] { r }); Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(new[] { t }); await _sut.Process(); Serilog.Verify(l => l.Information("Tag {repo}:{name} skipped due to global ignore rules", t.Repository, t.Name), Times.Once); Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public async Task UnmatchedTagsAreKeptImplicitly() { _ruleSet.DefaultRule.Tag = new Regex("^$"); var tags = _fixture.CreateMany <Tag>(10); Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(tags); await _sut.Process(); Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never); Serilog.Verify(l => l.Warning("The default rule did not match all remaining tags for {@repo}. {count} remaining tags will be kept", _repository, 10), Times.Once); }
public async Task SkipsHarbor14CorruptTags() { var tag = _fixture.Build <Tag>() .WithAutoProperties() .Without(t => t.Digest) .Create(); Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(new[] { tag }); await _sut.Process(); Serilog.Verify(l => l.Warning("Tag {repo}:{name} does not have a digest and was likely corrupted during a delete operation. This tag will be skipped. See https://github.com/vmware/harbor/issues/4214 for details", tag.Repository, tag.Name), Times.Once); Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public SerilogLogger(Serilog.ILogger baseLogger = null, bool demoteDebug = false) { _baseLogger = baseLogger; _demoteDebug = demoteDebug; _logs = new ConcurrentDictionary<string, ILog>(); }
public void broadcastLogEvent(Serilog.Sinks.SignalR.Data.LogEvent log) { Clients.All.broadcastLogEvent(log); }
/// <summary> /// Create a logger factory. /// </summary> /// <param name="logger">The logger; if not provided the global <see cref="Log.Logger"/> will be used.</param> /// <param name="getLogEventLevel"></param> public LoggerFactory(Serilog.ILogger logger = null, Func<TraceEventType, LogEventLevel> getLogEventLevel = null) { _getLogger = logger == null ? (Func<Serilog.ILogger>)(() => Serilog.Log.Logger) : (() => logger); _getLogEventLevel = getLogEventLevel ?? ToLogEventLevel; }
public ZipPackageBuilder(IOctopusFileSystem fileSystem, Serilog.ILogger log) { this.fileSystem = fileSystem; this.log = log; }
internal Logger(Serilog.ILogger logger, Func<TraceEventType, LogEventLevel> getLogEventLevel) { _logger = logger; _getLogEventLevel = getLogEventLevel; }
public SerilogLogger(Serilog.ILogger baseLogger = null, bool demoteDebug = false) { _baseLogger = baseLogger; this._demoteDebug = demoteDebug; _logs = new MemoryCache("MassTransit.SerilogIntegration"); }
private SerilogLogger(Serilog.ILogger logger) { _log = logger; }
public PackageVersionResolver(Serilog.ILogger log) { this.log = log; }
public static void Use(Serilog.ILogger baseLogger) { Logger.UseLogger(new SerilogLogger(baseLogger)); }
/// <summary> /// Use Serilog for logging in Mass Transit. If no Serilog ILogger instance is provided, /// use the Log.Logger global instance. /// </summary> /// <param name="baseLogger"></param> /// <param name="demoteDebug"></param> public static void Use(Serilog.ILogger baseLogger = null, bool demoteDebug = false) { Logging.Logger.UseLogger(new SerilogLogger(baseLogger, demoteDebug)); }
public SerilogLogger(Serilog.ILogger logger) { this.logger = logger; }
public SerilogWrapper(Serilog.ILogger log) { _log = log; }
public SerilogLogger( Serilog.ILogger logger ) { Logger = logger; }
public SerilogLogger(Serilog.ILogger baseLogger) { _baseLogger = baseLogger; _logs = new MemoryCache("MassTransit.SerilogIntegration"); }