public DropshippingJobs(DropshipAccountsPostgres dbAccounts, DropshipItemsPostgres dbItems, DropshippingService dropship, IRavenClient raven) { this.dbAccounts = dbAccounts; this.dbItems = dbItems; this.raven = raven; this.dropship = dropship; }
public LogModule(IRavenClient ravenClient) { Get["/log"] = _ => { var messageId = ravenClient.CaptureMessage("Hello world !!!"); return View["log.html", new { MessageId = messageId }]; }; Get["/log-async", runAsync : true] = async (_, token) => { var httpClient = new HttpClient(); var response = await httpClient.GetAsync("http://www.google.com"); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsStringAsync(); #if (!net40) var messageId = await ravenClient.CaptureMessageAsync("Hello world!!!"); #else var messageId = ravenClient.CaptureMessage("Hello world!!!"); #endif return View["log.html", new { MessageId = messageId }]; }; }
public SearchCache(IApplicationCache cache, ISearchPostgres db, WebSearchService[] services, IRavenClient raven) { this.cache = cache; this.db = db; this.raven = raven; this.webServices = services; }
public LogModule(IRavenClient ravenClient) { Get["/log"] = _ => { var messageId = ravenClient.CaptureMessage("Hello world !!!"); return(View["log.html", new { MessageId = messageId }]); }; Get["/log-async", runAsync : true] = async(_, token) => { var httpClient = new HttpClient(); var response = await httpClient.GetAsync("http://www.google.com"); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsStringAsync(); #if (!net40) && (!net35) var messageId = await ravenClient.CaptureMessageAsync("Hello world!!!"); #else var messageId = ravenClient.CaptureMessage("Hello world!!!"); #endif return(View["log.html", new { MessageId = messageId }]); }; }
public AliexpressService(IHttpService http, ISearchPostgres db, IRavenClient raven) : base(SearchServiceType.Aliexpress) { this.http = http; this.db = db; this.raven = raven; }
/// <summary> /// Initializes a new instance of the <see cref="SentryRequestStartup"/> class. /// </summary> /// <param name="ravenClient">The raven client.</param> /// <exception cref="System.ArgumentNullException">ravenClient</exception> public SentryRequestStartup(IRavenClient ravenClient) { if (ravenClient == null) throw new ArgumentNullException("ravenClient"); this.ravenClient = ravenClient; }
public DHGateService(IHttpService http, IApplicationCache cache, IRavenClient raven) : base(SearchServiceType.DHGate) { this.http = http; this.cache = cache; this.raven = raven; }
public Logger(RequestDelegate next, ILogger <Logger> logger, ILoggingService appLogging, IRavenClient raven) { this._next = next; this.logger = logger; this.appLogging = appLogging; this.raven = raven; }
public void CaptureException_CanLogException_If_Send_Fails() { const string dsnUri = "http://*****:*****@totally.notexisting.xyz/666"; Exception hookedException = null; this.ravenClient = new RavenClient(dsnUri) { ErrorOnCapture = exp => hookedException = exp }; Helper.PrintInfo("In test client change!"); Helper.PrintInfo("Sentry Uri: " + this.ravenClient.CurrentDsn.SentryUri); Helper.PrintInfo("Port: " + this.ravenClient.CurrentDsn.Port); Helper.PrintInfo("Public Key: " + this.ravenClient.CurrentDsn.PublicKey); Helper.PrintInfo("Private Key: " + this.ravenClient.CurrentDsn.PrivateKey); Helper.PrintInfo("Project ID: " + this.ravenClient.CurrentDsn.ProjectID); try { Helper.FirstLevelException(); } catch (Exception e) { this.ravenClient.CaptureException(e); } Assert.That(hookedException, Is.Not.Null); }
public static async Task <string> CaptureNetCoreEventAsync(this IRavenClient client, SentryEvent @event) { //Add "beautified" async recovery data @event.Exception.Data.Add("AsyncStackTrace", @event.Exception.StackTraceEx()); return(await CaptureNetCoreEvent(client, @event)); }
//private readonly ILogger _loggerFactory; public ExceptionHandlerMiddleware(RequestDelegate next, TelemetryClient telemetryClient, IRavenClient client) //ILogger loggerFactory, { _next = next; _telemetryClient = telemetryClient; //_loggerFactory = loggerFactory; _client = client; }
public ExceptionHandler(RequestDelegate next, ILogger <ExceptionHandler> logger, ILoggingService dbLog, IRavenClient raven) { _next = next; this.logger = logger; this.dbLog = dbLog; this.raven = raven; }
public static async Task <string> CaptureNetCoreEvent(this IRavenClient client, SentryEvent @event) { /*//Do not send errors during development * if (client.Environment == "Development") * return "development";*/ return(await client.CaptureAsync(@event)); }
/// <summary> /// Initializes a new instance of the <see cref="SentryLogger" /> class. /// </summary> /// <param name="name">The name of the logger.</param> /// <param name="client">The Sentry.io client.</param> public SentryLogger(string name, IRavenClient client) { Ensure.String.IsNotNullOrEmpty(name, nameof(name)); Ensure.Any.IsNotNull(client, nameof(client)); _name = name; _client = client; }
protected virtual void SendAuthRequest(IRavenClient client, string username, string password) { client.Send(new AuthRequest() { Username = username, Password = password }, SendOption.Reliable); }
public SentryErrorHandlerModule() { _appConfig = new AppConfig(); if (_appConfig.IsProductionEnvironment) { _ravenClient = new RavenClient(_appConfig.SentryDsn); } }
public SearchService(WebSearchService[] services, ISearchPostgres db, IApplicationCache cache, IRavenClient raven, SearchCache searchCache) { this.raven = raven; this.db = db; this.cache = cache; this.services = services; this.searchCache = searchCache; }
/// <summary> /// Initializes a new instance of the <see cref="SentryRequestStartup"/> class. /// </summary> /// <param name="ravenClient">The raven client.</param> /// <exception cref="System.ArgumentNullException">ravenClient</exception> public SentryRequestStartup(IRavenClient ravenClient) { if (ravenClient == null) { throw new ArgumentNullException("ravenClient"); } this.ravenClient = ravenClient; }
/// <summary> /// Initializes a new instance of the <see cref="SentryErrorReporter" /> class. /// </summary> /// <param name="dsn">The dsn.</param> /// <exception cref="System.ArgumentNullException"> /// options /// or /// Can not construct a SentryErrorReporter without a valid DSN! /// </exception> public SentryErrorReporter(string dsn) { if (string.IsNullOrEmpty(dsn)) { throw new ArgumentNullException("Can not construct a SentryErrorReporter without a valid DSN!"); } _client = new RavenClient(dsn); }
public UserService(IJwtFactory jwtFactory, IUsersPostgres db, ISecurityHasher hasher, IEmailService email, IRavenClient raven, DropshippingService dropship) { this.jwtFactory = jwtFactory; this.db = db; this.hasher = hasher; this.email = email; this.raven = raven; this.dropship = dropship; }
//Setup this class as a Scoped dependency injection and call SetupScope public ShopifyService(IHttpService http, IApplicationCache cache, ShopifyOAuth oauth, OAuthPostgres oauthDb, OAuthService oauthRetriever, IRavenClient raven, IOptions <ShopifyOptions> config) { this.http = http; this.raven = raven; this.config = config.Value; this.oauthDb = oauthDb; this.cache = cache; this.oauthRetriever = oauthRetriever; }
public DropshippingController(DropshippingService dropship, ISearchService search, ShopifyService shopify, OAuthService oauthdb, DropshipItemsPostgres dbItems, DropshipAccountsPostgres dbAccounts, IRavenClient raven) { this.dropship = dropship; this.raven = raven; this.shopify = shopify; this.oauthdb = oauthdb; this.dbItems = dbItems; this.dbAccounts = dbAccounts; this.search = search; }
public SerilogMiddleware(RequestDelegate next, IRavenClient ravenClient, AppSettings appSettings, IEmailService EmailService) { if (next == null) { throw new ArgumentNullException(nameof(next)); } _next = next; _RavenClient = ravenClient; _AppSettings = appSettings; _EmailService = EmailService; }
/// <summary> /// Adds the Sentry logger provider to the specified factory /// </summary> /// <param name="factory">The factory.</param> /// <param name="client">The Sentry client.</param> /// <returns>The logger factory</returns> public static ILoggerFactory AddSentry(this ILoggerFactory factory, IRavenClient client) { Ensure.Any.IsNotNull(factory, nameof(factory)); Ensure.Any.IsNotNull(client, nameof(client)); var provider = new SentryLoggerProvider(client); factory.AddProvider(provider); return(factory); }
public static void CatchAllUnhandledException(Action <IRavenClient> action, IRavenClient ravenClent) { try { action(ravenClent); } catch (Exception ex) { ravenClent.Capture(new SentryEvent(ex)); throw; } }
// Start is called before the first frame update private void Start() { logger = GameObject.FindObjectOfType <GameUILog>(); gameClient = IoCContainer.Instance.Resolve <IRavenClient>(); Auth = gameClient.Modules.GetModule <Authentication>(); PlayerHandler = gameClient.Modules.GetModule <PlayerHandler>(); ObjectHandler = gameClient.Modules.GetModule <ObjectHandler>(); NpcHandler = gameClient.Modules.GetModule <NpcHandler>(); CharacterHandler = gameClient.Modules.GetModule <CharacterHandler>(); ChatMessageHandler = gameClient.Modules.GetModule <ChatMessageHandler>(); //Connect(); }
public static async Task <string> CaptureNetCoreEvent(this IRavenClient client, Exception e) { //Do not send errors during development if (client.Environment == "Development") { return("development"); } SentryEvent @event = new SentryEvent(e); return(await client.CaptureAsync(@event)); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("MyPolicy"); app.UseAuthentication(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1"); }); app.UseExceptionHandler( builder => { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { IRavenClient ravenClient = serviceScope.ServiceProvider.GetService <IRavenClient>(); builder.Run(async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.ContentType = "application/json"; IExceptionHandlerFeature ex = context.Features.Get <IExceptionHandlerFeature>(); if (ex != null) { var err = JsonConvert.SerializeObject(new Error() { Stacktrace = ex.Error.StackTrace, Message = ex.Error.Message }); await context.Response.Body.WriteAsync(Encoding.ASCII.GetBytes(err), 0, err.Length).ConfigureAwait(false); } }); } } ); using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { serviceScope.ServiceProvider.GetService <DatabaseContext>().Database.Migrate(); } app.UseStaticFiles(); app.UseMvc(); CultureInfo cultureInfo = new CultureInfo("pt-BR"); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; }
public RavenfallServerConnection( ILogger logger, IRavenfallServerSettings settings, IRavenClient gameClient) { this.logger = logger; this.settings = settings; this.gameClient = gameClient; this.gameClient.Auth.LoginFailed += OnLoginFailed; this.gameClient.Auth.LoginSuccess += OnLoginSuccess; this.gameClient.Connected += OnConnect; this.gameClient.Disconnected += OnDisconnect; }
public SentryErrorReporter(IOptions <SentryOptions> options) { //if (options == null) //{ // throw new ArgumentNullException(typeof(options));//hata olarak =>ArgumentNullException fırlat. //} if (string.IsNullOrEmpty(options.Value.DNS)) { //hata olarak =>ArgumentNullException fırlat. throw new ArgumentNullException("Can not construct a SentryErrorReporter witouth a valid DNS..!"); } _client = new RavenClient(options.Value.DNS); }
public ApiService(IHttpContextAccessor accessor, ILogger <ApiService> logger, IOptions <ApiOptions> config, IRavenClient raven) { context = accessor.HttpContext; this.logger = logger; address = config.Value.Host; port = config.Value.Port; this.raven = raven; }
/// <summary> /// Appends the specified logging event. /// </summary> /// <param name="loggingEvent">The logging event.</param> protected override void Append(LoggingEvent loggingEvent) { if (RavenClient == null) { RavenClient = new RavenClient(DSN) { Logger = Logger, Release = Assembly.GetExecutingAssembly().GetName().Version.ToString(), // If something goes wrong when sending the event to Sentry, make sure this is written to log4net's internal // log. See <add key="log4net.Internal.Debug" value="true"/> ErrorOnCapture = ex => LogLog.Error(typeof(SentryAppender), "[" + Name + "] " + ex.Message, ex), }; } var tags = tagLayouts.ToDictionary(t => t.Name, t => (t.Layout.Format(loggingEvent) ?? "").ToString()); Exception exception = loggingEvent.ExceptionObject ?? loggingEvent.MessageObject as Exception; ErrorLevel level = Translate(loggingEvent.Level); SentryEvent sentryEvent; if (loggingEvent.ExceptionObject != null) { // We should capture buth the exception and the message passed sentryEvent = new SentryEvent(exception); } else if (loggingEvent.MessageObject is Exception) { // We should capture the exception with no custom message sentryEvent = new SentryEvent((Exception)loggingEvent.MessageObject); } else { // Just capture message var message = loggingEvent.RenderedMessage; sentryEvent = new SentryEvent(new SentryMessage(message, level, tags)); } sentryEvent.Extra = new { Environment = new EnvironmentExtra() }; if (loggingEvent.Level.DisplayName == "ERROR" || loggingEvent.Level.DisplayName == "FETAL") { RavenClient.Capture(sentryEvent); } else { RavenClient.CaptureAsync(sentryEvent); } }
/// <summary> /// Initializes a new instance of the <see cref="SentryErrorReporter" /> class. /// </summary> /// <param name="options">The options.</param> /// <exception cref="System.ArgumentNullException"> /// options /// or /// Can not construct a SentryErrorReporter without a valid DSN! /// </exception> public SentryErrorReporter(IOptions <SentrySetup> options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (string.IsNullOrEmpty(options.Value.Dsn)) { throw new ArgumentNullException("Can not construct a SentryErrorReporter without a valid DSN!"); } _client = new RavenClient(options.Value.Dsn); }
public void Setup() { Console.WriteLine("Initializing RavenClient."); this.ravenClient = new RavenClient(DsnUrl) { Logger = "C#", LogScrubber = new LogScrubber() }; Helper.PrintInfo("Sentry Uri: " + this.ravenClient.CurrentDsn.SentryUri); Helper.PrintInfo("Port: " + this.ravenClient.CurrentDsn.Port); Helper.PrintInfo("Public Key: " + this.ravenClient.CurrentDsn.PublicKey); Helper.PrintInfo("Private Key: " + this.ravenClient.CurrentDsn.PrivateKey); Helper.PrintInfo("Project ID: " + this.ravenClient.CurrentDsn.ProjectID); }
public void CaptureMessage_CanLogException_If_Send_Fails() { const string dsnUri = "http://*****:*****@totally.notexisting.xyz/666"; Exception hookedException = null; this.ravenClient = new RavenClient(dsnUri) { ErrorOnCapture = exp => hookedException = exp }; Helper.PrintInfo("In test client change!"); Helper.PrintInfo("Sentry Uri: " + this.ravenClient.CurrentDsn.SentryUri); Helper.PrintInfo("Port: " + this.ravenClient.CurrentDsn.Port); Helper.PrintInfo("Public Key: " + this.ravenClient.CurrentDsn.PublicKey); Helper.PrintInfo("Private Key: " + this.ravenClient.CurrentDsn.PrivateKey); Helper.PrintInfo("Project ID: " + this.ravenClient.CurrentDsn.ProjectID); this.ravenClient.CaptureMessage("Test message"); Assert.NotNull(hookedException); }
public void CaptureMessage_Doesnt_Fail_On_Error_During_Send() { const string dsnUri = "http://*****:*****@totally.notexisting.xyz/666"; this.ravenClient = new RavenClient(dsnUri); Helper.PrintInfo("In test client change!"); Helper.PrintInfo("Sentry Uri: " + this.ravenClient.CurrentDsn.SentryUri); Helper.PrintInfo("Port: " + this.ravenClient.CurrentDsn.Port); Helper.PrintInfo("Public Key: " + this.ravenClient.CurrentDsn.PublicKey); Helper.PrintInfo("Private Key: " + this.ravenClient.CurrentDsn.PrivateKey); Helper.PrintInfo("Project ID: " + this.ravenClient.CurrentDsn.ProjectID); Assert.DoesNotThrow(() => this.ravenClient.CaptureMessage("Test message")); }
public void SetRavenClient(IRavenClient ravenClient) { RavenClient = ravenClient; }
public void CaptureException_Doesnt_Fail_On_Error_During_Send() { const string dsnUri = "http://*****:*****@totally.notexisting.xyz/666"; this.ravenClient = new RavenClient(dsnUri); Helper.PrintInfo("In test client change!"); Helper.PrintInfo("Sentry Uri: " + this.ravenClient.CurrentDsn.SentryUri); Helper.PrintInfo("Port: " + this.ravenClient.CurrentDsn.Port); Helper.PrintInfo("Public Key: " + this.ravenClient.CurrentDsn.PublicKey); Helper.PrintInfo("Private Key: " + this.ravenClient.CurrentDsn.PrivateKey); Helper.PrintInfo("Project ID: " + this.ravenClient.CurrentDsn.ProjectID); try { Helper.FirstLevelException(); } catch (Exception e) { Assert.DoesNotThrow(() => this.ravenClient.CaptureException(e)); } }
protected override void Append(LoggingEvent loggingEvent) { if (RavenClient == null) { RavenClient = new RavenClient(DSN) { Logger = Logger, // If something goes wrong when sending the event to Sentry, make sure this is written to log4net's internal // log. See <add key="log4net.Internal.Debug" value="true"/> ErrorOnCapture = ex => LogLog.Error(typeof (SentryAppender), "[" + Name + "] " + ex.Message, ex) }; } var httpExtra = HttpExtra.GetHttpExtra(); object extra; if (httpExtra != null) { extra = new { Environment = new EnvironmentExtra(), Http = httpExtra }; } else { extra = new { Environment = new EnvironmentExtra() }; } var tags = tagLayouts.ToDictionary(t => t.Name, t => (t.Layout.Format(loggingEvent) ?? "").ToString()); var exception = loggingEvent.ExceptionObject ?? loggingEvent.MessageObject as Exception; var level = Translate(loggingEvent.Level); if (loggingEvent.ExceptionObject != null) { // We should capture buth the exception and the message passed RavenClient.CaptureException(exception, new SentryMessage(loggingEvent.RenderedMessage), level, tags: tags, extra: extra); } else if (loggingEvent.MessageObject is Exception) { // We should capture the exception with no custom message RavenClient.CaptureException(loggingEvent.MessageObject as Exception, null, level, tags: tags, extra: extra); } else { // Just capture message var message = loggingEvent.RenderedMessage; if (message != null) { RavenClient.CaptureMessage(message, level, tags, extra); } } }