noasentry

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

Noa Sentry

A Sentry integration module for Noa Log that allows quick integration of Noa with Sentry. It automatically sends errors to Sentry when print errors.

Installation

go get -u github.com/noa-log/noa-sentry

Quick Start

package main

import (
    "errors"
    "os"
    "time"

    "github.com/getsentry/sentry-go"
    "github.com/noa-log/noa"
    "github.com/noa-log/noa-sentry"
)

func main() {
    // Get Dsn from environment variable
    Dsn := os.Getenv("SENTRY_DSN")

    // Initialize Sentry
    err := sentry.Init(sentry.ClientOptions{
        Dsn:   Dsn,
        Debug: true,
    })
    if err != nil {
        panic(err)
    }
    defer sentry.Flush(2 * time.Second)

    // Create a new logger instance
    logger := noa.NewLog()

    // Register the Sentry Handler
    logger.AddAfterHandle(noasentry.CaptureHandler)

    // Log an error
    err = errors.New("An example error")
    logger.Error("Test", err)
}

License

This project is open-sourced under the Apache License 2.0. Please comply with the terms when using it.

Documentation

Overview

* @Author: nijineko * @Date: 2025-06-11 12:04:18 * @LastEditTime: 2025-06-11 12:12:56 * @LastEditors: nijineko * @Description: noa sentry handler * @FilePath: \noa-sentry\sentry.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureHandler

func CaptureHandler(Level int, Source string, Data ...any) error

*

  • @description: error capture handler
  • @param {int} Level
  • @param {string} Source
  • @param {...any} Data
  • @return {error} error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL