コード例 #1
0
        internal SentryLoggerProvider(
            IHub hub,
            ISystemClock clock,
            SentryLoggingOptions options)
        {
            _disposableHub = hub as IDisposable;

            Hub      = hub;
            _clock   = clock;
            _options = options;

            if (hub.IsEnabled)
            {
                _scope = hub.PushScope();
                hub.ConfigureScope(s =>
                {
                    if (s.Sdk is { } sdk)
                    {
                        sdk.Name    = Constants.SdkName;
                        sdk.Version = NameAndVersion.Version;

                        if (NameAndVersion.Version is { } version)
                        {
                            sdk.AddPackage(ProtocolPackageName, version);
                        }
                    }
                });

                // Add scope configuration to hub from options
                foreach (var callback in options.ConfigureScopeCallbacks)
                {
                    hub.ConfigureScope(callback);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Applies the default tags to an event without resetting existing tags.
 /// </summary>
 /// <param name="options">The options to read the default tags from.</param>
 /// <param name="event">The event to apply the tags to.</param>
 public static void ApplyDefaultTags(this SentryLoggingOptions options, SentryEvent @event)
 {
     foreach (var defaultTag in options.DefaultTags
              .Where(t => [email protected](t.Key, out _)))
     {
         @event.SetTag(defaultTag.Key, defaultTag.Value);
     }
 }
コード例 #3
0
ファイル: SentryLogger.cs プロジェクト: robopsi/sentry-dotnet
 public SentryLogger(
     string categoryName,
     SentryLoggingOptions options)
     : this(
         categoryName,
         options,
         SystemClock.Clock,
         SentryCoreAdapter.Instance)
 {
 }
コード例 #4
0
 internal SentryLogger(
     string categoryName,
     SentryLoggingOptions options,
     ISystemClock clock,
     IHub hub)
 {
     CategoryName = categoryName;
     _options     = options;
     _clock       = clock;
     _hub         = hub;
 }
コード例 #5
0
        internal SentryLoggerProvider(
            ISentryScopeManagement scopeManagement,
            SentryLoggingOptions options)
        {
            Debug.Assert(options != null);
            Debug.Assert(scopeManagement != null);

            _options = options;
            // Creates a scope so that Integration added below can be dropped when the logger is disposed
            _scope = scopeManagement.PushScope();

            scopeManagement.ConfigureScope(p => p.Sdk.Integrations.Add(Constants.IntegrationName));
        }
コード例 #6
0
ファイル: SentryLogger.cs プロジェクト: robopsi/sentry-dotnet
 internal SentryLogger(
     string categoryName,
     SentryLoggingOptions options,
     ISystemClock clock,
     ISentryClient sentryClient)
 {
     Debug.Assert(categoryName != null);
     Debug.Assert(options != null);
     Debug.Assert(clock != null);
     Debug.Assert(sentryClient != null);
     CategoryName  = categoryName;
     _options      = options;
     _clock        = clock;
     _sentryClient = sentryClient;
 }
コード例 #7
0
 internal SentryLogger(
     string categoryName,
     SentryLoggingOptions options,
     ISystemClock clock,
     IHub hub)
 {
     Debug.Assert(categoryName != null);
     Debug.Assert(options != null);
     Debug.Assert(clock != null);
     Debug.Assert(hub != null);
     CategoryName = categoryName;
     _options     = options;
     _clock       = clock;
     _hub         = hub;
 }
コード例 #8
0
        internal SentryLoggerProvider(
            ISentryScopeManager scopeManager,
            SentryLoggingOptions options)
        {
            Debug.Assert(options != null);
            Debug.Assert(scopeManager != null);

            _options = options;

            // SDK is being initialized through this integration
            // Lifetime is owned by this instance:
            if (_options.InitializeSdk)
            {
                _sdk = SentryCore.Init(_options.InitSdk);
            }

            // Creates a scope so that Integration added below can be dropped when the logger is disposed
            _scope = scopeManager.PushScope();

            // TODO: SDK interface not accepting 'Integrations'
            // scopeManager.ConfigureScope(s => s.Sdk.AddIntegration(Constants.IntegrationName));
        }
コード例 #9
0
 /// <summary>
 /// Add an log event filter
 /// </summary>
 /// <remarks>
 /// Filters are called before sending an event.
 /// This allows the filter to decide whether the log message should not be recorded at all.
 /// </remarks>
 /// <param name="options">The <see cref="SentryLoggingOptions"/> to hold the filter.</param>
 /// <param name="filter">The filter.</param>
 public static void AddLogEntryFilter(
     this SentryLoggingOptions options,
     Func <string, LogLevel, EventId, Exception?, bool> filter)
 => options.AddLogEntryFilter(new DelegateLogEntryFilter(filter));
コード例 #10
0
 /// <summary>
 /// Add an log event filter
 /// </summary>
 /// <remarks>
 /// Filters are called before sending an event.
 /// This allows the filter to decide whether the log message should not be recorded at all.
 /// </remarks>
 /// <param name="options">The <see cref="SentryLoggingOptions"/> to hold the filter.</param>
 /// <param name="filter">The filter.</param>
 public static void AddLogEntryFilter(this SentryLoggingOptions options, ILogEntryFilter filter)
 => options.Filters = options.Filters.Concat(new[] { filter }).ToArray();
コード例 #11
0
 /// <summary>
 /// Add an log event filter
 /// </summary>
 /// <remarks>
 /// Filters are called before sending an event.
 /// This allows the filter to decide whether the log message should not be recorded at all.
 /// </remarks>
 /// <param name="options">The <see cref="SentryLoggingOptions"/> to hold the filter.</param>
 /// <param name="filter">The filter.</param>
 public static void AddLogEntryFilter(this SentryLoggingOptions options, ILogEntryFilter filter)
 => options.Filters = options.Filters.Add(filter);
コード例 #12
0
 public SentryLoggerProvider(SentryLoggingOptions options)
     : this(SentryCoreAdapter.Instance, options)
 {
 }