Skip to content

Commit

Permalink
replace LogglyHost with LogglyTag (stellar#589)
Browse files Browse the repository at this point in the history
* parameterise LogglyTag, defaults to horizon
  • Loading branch information
brahman81 authored and Robert Durst committed Aug 15, 2018
1 parent 4410488 commit 9c7a0e3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion services/horizon/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Config struct {
FriendbotURL string
LogLevel logrus.Level
SentryDSN string
LogglyHost string
LogglyTag string
LogglyToken string
// TLSCert is a path to a certificate file to use for horizon's TLS config
TLSCert string
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/init_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func initLogglyLog(app *App) {

log.WithFields(log.F{
"token": app.config.LogglyToken,
"loggly_host": app.config.LogglyHost,
"tag": app.config.LogglyTag,
}).Info("Initializing loggly hook")

hook := log.NewLogglyHook(app.config.LogglyToken)
hook := log.NewLogglyHook(app.config.LogglyToken, app.config.LogglyTag)
log.DefaultLogger.Logger.Hooks.Add(hook)

go func() {
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/log/loggly_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type LogglyHook struct {
}

// NewLogglyHook creates a new hook
func NewLogglyHook(token string) *LogglyHook {
client := loggly.New(token, "horizon")
func NewLogglyHook(token, tag string) *LogglyHook {
client := loggly.New(token, tag)
host, err := os.Hostname()

if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions services/horizon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func init() {
viper.BindEnv("log-level", "LOG_LEVEL")
viper.BindEnv("sentry-dsn", "SENTRY_DSN")
viper.BindEnv("loggly-token", "LOGGLY_TOKEN")
viper.BindEnv("loggly-host", "LOGGLY_HOST")
viper.BindEnv("loggly-tag", "LOGGLY_TAG")
viper.BindEnv("tls-cert", "TLS_CERT")
viper.BindEnv("tls-key", "TLS_KEY")
viper.BindEnv("ingest", "INGEST")
Expand Down Expand Up @@ -115,9 +115,9 @@ func init() {
)

rootCmd.PersistentFlags().String(
"loggly-host",
"",
"Hostname to be added to every loggly log event",
"loggly-tag",
"horizon",
"Tag to be added to every loggly log event",
)

rootCmd.PersistentFlags().String(
Expand Down Expand Up @@ -213,7 +213,7 @@ func initConfig() {
LogLevel: ll,
SentryDSN: viper.GetString("sentry-dsn"),
LogglyToken: viper.GetString("loggly-token"),
LogglyHost: viper.GetString("loggly-host"),
LogglyTag: viper.GetString("loggly-tag"),
TLSCert: cert,
TLSKey: key,
Ingest: viper.GetBool("ingest"),
Expand Down
4 changes: 2 additions & 2 deletions support/log/loggly_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

// NewLogglyHook creates a new hook
func NewLogglyHook(token string) *LogglyHook {
client := loggly.New(token, "horizon")
func NewLogglyHook(token, tag string) *LogglyHook {
client := loggly.New(token, tag)
host, err := os.Hostname()

if err != nil {
Expand Down

0 comments on commit 9c7a0e3

Please sign in to comment.