Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor New() function and use one config argument #51

Open
evalphobia opened this issue Jun 14, 2017 · 0 comments
Open

Refactor New() function and use one config argument #51

evalphobia opened this issue Jun 14, 2017 · 0 comments

Comments

@evalphobia
Copy link
Owner

There are many New... method to create *SentryHook.
To scale configuration, add a config struct and use it in New() function.

For example below,

// something like this
type Config struct {
    Levels []logrus.Level
    StacktraceConfiguration

    DSN string
    Async bool
    Tags map[string]string
    Release string
    Environment string
    // etc...
}

func New(conf Config) (*SentryHook, error) {
    client, err := raven.NewWithTags(conf.DSN, conf.Tags)
    if err != nil {
        return nil, err
    }

    if conf.Release != "" {
        client.SetRelease(conf.Release)
    }
    if conf.Environment != "" {
        client.SetEnvironment(conf.Environment)
    }

    hook := &SentryHook{
        asynchronous: conf.Async,
    }
   // etc...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant