コード例 #1
1
ファイル: SerilogModule.cs プロジェクト: automagic/poshgit2
 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);
             }
         };
     }
 }
コード例 #2
1
 public SerilogLogger(Serilog.ILogger logger)
 {
     log = logger;
 }
コード例 #3
1
ファイル: Logger.cs プロジェクト: JudoPay/DotNetSDK
 public Logger(Serilog.ILogger logger)
 {
     _logger = logger;
 }
コード例 #4
0
        // 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()));
        }
コード例 #5
0
        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;
        }
コード例 #7
0
 public static void AddSerilog(Serilog.ILogger logger = null)
 {
    var factory = GetFactory();
    lock(s_syncLock)
     {
         
          Serilog.SerilogLoggerFactoryExtensions.AddSerilog(factory, logger);
         
     }    
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: SeriLogLogger.cs プロジェクト: phatboyg/MassTransit
 public SerilogLogger(Serilog.ILogger baseLogger = null, bool demoteDebug = false)
 {
     _baseLogger = baseLogger;
     _demoteDebug = demoteDebug;
     _logs = new ConcurrentDictionary<string, ILog>();
 }
コード例 #15
0
ファイル: OpenBookHub.cs プロジェクト: reeseoo/OpenBookAPI
 public void broadcastLogEvent(Serilog.Sinks.SignalR.Data.LogEvent log)
 {
     Clients.All.broadcastLogEvent(log);
 }
コード例 #16
0
ファイル: LoggerFactory.cs プロジェクト: tachyony/BigData
 /// <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;
 }
コード例 #17
0
 public ZipPackageBuilder(IOctopusFileSystem fileSystem, Serilog.ILogger log)
 {
     this.fileSystem = fileSystem;
     this.log = log;
 }
コード例 #18
0
ファイル: LoggerFactory.cs プロジェクト: tachyony/BigData
 internal Logger(Serilog.ILogger logger, Func<TraceEventType, LogEventLevel> getLogEventLevel)
 {
     _logger = logger;
     _getLogEventLevel = getLogEventLevel;
 }
コード例 #19
0
 public SerilogLogger(Serilog.ILogger baseLogger = null, bool demoteDebug = false)
 {
     _baseLogger = baseLogger;
     this._demoteDebug = demoteDebug;
     _logs = new MemoryCache("MassTransit.SerilogIntegration");
 }
コード例 #20
0
ファイル: SerilogLogger.cs プロジェクト: loonison101/PB
 private SerilogLogger(Serilog.ILogger logger)
 {
     _log = logger;
 }
コード例 #21
0
 public PackageVersionResolver(Serilog.ILogger log)
 {
     this.log = log;
 }
コード例 #22
0
 public static void Use(Serilog.ILogger baseLogger)
 {
     Logger.UseLogger(new SerilogLogger(baseLogger));
 }
コード例 #23
0
ファイル: SeriLogLogger.cs プロジェクト: phatboyg/MassTransit
 /// <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));
 }
コード例 #24
0
ファイル: SerilogLogger.cs プロジェクト: Stavrakakis/Patterns
 public SerilogLogger(Serilog.ILogger logger)
 {
     this.logger = logger;
 }
コード例 #25
0
ファイル: SerilogWrapper.cs プロジェクト: automagic/poshgit2
 public SerilogWrapper(Serilog.ILogger log)
 {
     _log = log;
 }
コード例 #26
0
ファイル: SerilogLogger.cs プロジェクト: slav/Netco
 public SerilogLogger( Serilog.ILogger logger )
 {
     Logger = logger;
 }
コード例 #27
0
 public SerilogLogger(Serilog.ILogger baseLogger)
 {
     _baseLogger = baseLogger;
     _logs = new MemoryCache("MassTransit.SerilogIntegration");
 }