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); } } }
/// <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); } }
public SentryLogger( string categoryName, SentryLoggingOptions options) : this( categoryName, options, SystemClock.Clock, SentryCoreAdapter.Instance) { }
internal SentryLogger( string categoryName, SentryLoggingOptions options, ISystemClock clock, IHub hub) { CategoryName = categoryName; _options = options; _clock = clock; _hub = hub; }
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)); }
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; }
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; }
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)); }
/// <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));
/// <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();
/// <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);
public SentryLoggerProvider(SentryLoggingOptions options) : this(SentryCoreAdapter.Instance, options) { }