Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollbarLogger" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="rollbarConfig">The rollbar configuration.</param>
        /// <param name="rollbarOptions">The options.</param>
        /// <param name="httpContextAccessor">The HTTP context accessor.</param>
        public RollbarLogger(string name
                             , IRollbarConfig rollbarConfig
                             , RollbarOptions rollbarOptions
                             , IHttpContextAccessor httpContextAccessor
                             )
        {
            this._name                = name;
            this._rollbarOptions      = rollbarOptions;
            this._httpContextAccessor = httpContextAccessor;

            this._rollbar = RollbarFactory.CreateNew(rollbarConfig);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollbarMiddleware" /> class.
        /// </summary>
        /// <param name="nextRequestProcessor">The next request processor.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="rollbarOptions">The rollbar options.</param>
        public RollbarMiddleware(
            RequestDelegate nextRequestProcessor
            , IConfiguration configuration
            , ILoggerFactory loggerFactory
            , IOptions <RollbarOptions> rollbarOptions
            )
        {
            this._nextRequestProcessor = nextRequestProcessor;
            this._logger         = loggerFactory.CreateLogger <RollbarMiddleware>();
            this._rollbarOptions = rollbarOptions.Value;

            RollbarConfigurationUtil.DeduceRollbarTelemetryConfig(configuration);
            TelemetryCollector.Instance.StartAutocollection();
            RollbarConfigurationUtil.DeduceRollbarConfig(configuration);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollbarLoggerProvider" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="options">The options.</param>
        /// <param name="httpContextAccessor">The HTTP context accessor.</param>
        public RollbarLoggerProvider(
            IConfiguration configuration
            , IOptions <RollbarOptions> options
            , IHttpContextAccessor httpContextAccessor
            )
        {
            Assumption.AssertNotNull(configuration, nameof(configuration));
            Assumption.AssertNotNull(options, nameof(options));

            RollbarConfigurationUtil.DeduceRollbarTelemetryConfig(configuration);
            TelemetryCollector.Instance.StartAutocollection();
            this._rollbarOptions      = options.Value;
            this._rollbarConfig       = RollbarConfigurationUtil.DeduceRollbarConfig(configuration);
            this._httpContextAccessor = httpContextAccessor;

            Assumption.AssertNotNull(this._rollbarConfig, nameof(this._rollbarConfig));
            Assumption.AssertNotNullOrWhiteSpace(this._rollbarConfig.AccessToken, nameof(this._rollbarConfig.AccessToken));
        }