/// <summary> /// configures an returns rollbar logger /// </summary> /// <returns></returns> protected static ILogger GetRollbarLogger() { if (RollbarConfigured) { return(RollbarLogger); } RollbarConfiguration rollbarCfg = null; #if NETSTANDARD2_0 || NETCOREAPP3_1 rollbarCfg = Cartomatic.Utils.NetCoreConfig.GetNetCoreConfig() .GetSection(nameof(RollbarConfiguration)) .Get <RollbarConfiguration>(); #endif #if NETFULL try { rollbarCfg = JsonConvert.DeserializeObject <RollbarConfiguration>( ConfigurationManager.AppSettings[nameof(RollbarConfiguration)]); } catch { //ignore } #endif if (rollbarCfg != null && !string.IsNullOrWhiteSpace(rollbarCfg.AccessToken)) { try { RollbarLocator.RollbarInstance.Configure(new RollbarConfig { AccessToken = rollbarCfg.AccessToken, Environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), Enabled = (rollbarCfg.Environments?.Select(x => x.ToLower()) ?? new string[0]).Contains( Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")?.ToLower()) }); RollbarLogger = RollbarLocator.RollbarInstance.Logger; } catch (Exception ex) { LogExceptions(ex); } } else { LogExceptions(new Exception("Rollbar could not be configured.")); } RollbarConfigured = true; return(RollbarLogger); }
//--- Contructors --- public PayloadBuilder(RollbarConfiguration configuration, IDataBuilder dataBuilder) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (dataBuilder == null) { throw new ArgumentNullException("dataBuilder"); } _configuration = configuration; _dataBuilder = dataBuilder; }
//--- Constructors --- public DataBuilder( RollbarConfiguration configuration, IBodyBuilder bodyBuilder, ITitleBuilder titleBuilder ) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (bodyBuilder == null) { throw new ArgumentNullException("bodyBuilder"); } if (titleBuilder == null) { throw new ArgumentNullException("titleBuilder"); } _configuration = configuration; _bodyBuilder = bodyBuilder; _titleBuilder = titleBuilder; }