Skip to content

Commit

Permalink
Added a bit of logging to provide feedback on what config file is used
Browse files Browse the repository at this point in the history
  • Loading branch information
noctarius committed Jun 24, 2023
1 parent 01ea827 commit a251b2c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/timescaledb-event-streamer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
verbose bool
withCaller bool
logToStdErr bool
versionOnly bool
)

func main() {
Expand Down Expand Up @@ -51,6 +52,11 @@ func main() {
Usage: "Redirects logging output to stderr, necessary when using StdOut as the sink",
Destination: &logToStdErr,
},
&cli.BoolFlag{
Name: "version",
Usage: "Prints the version and exits",
Destination: &versionOnly,
},
},
Action: start,
}
Expand All @@ -65,6 +71,10 @@ func start(*cli.Context) error {
version.BinName, version.Version, version.CommitHash, version.Branch,
)

if versionOnly {
return nil
}

logging.WithCaller = withCaller
logging.WithVerbose = verbose

Expand All @@ -73,11 +83,13 @@ func start(*cli.Context) error {
// No configuration file set? Try env variable!
if configurationFile == "" {
if cf, present := os.LookupEnv("TIMESCALEDB_EVENT_STREAMER_CONFIG"); present {
fmt.Fprintf(os.Stderr, "Using configuration file from environment variable\n")
configurationFile = cf
}
}

if configurationFile != "" {
fmt.Fprintf(os.Stderr, "Loading configuration file: %s\n", configurationFile)
f, err := os.Open(configurationFile)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Configuration file couldn't be opened: %v\n", err), 3)
Expand Down

0 comments on commit a251b2c

Please sign in to comment.