Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #38 from Netflix/add-disable-journald-hook
Browse files Browse the repository at this point in the history
Add mechanism to disable journald logging when executing titus-vpc-tool
  • Loading branch information
sargun authored Jan 26, 2018
2 parents b0c4885 + 29ff38a commit 222f918
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/titus-vpc-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func main() {
Name: "log-level",
Value: "info",
},
cli.BoolTFlag{
Name: "journald",
Usage: "Allows disabling the journald logging hook -- is enabled by default",
},
}
app.Commands = []cli.Command{
setup.Setup,
Expand Down
6 changes: 5 additions & 1 deletion vpc/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ type VPCContext struct {

func newVPCContext(cliContext *cli.Context) (*VPCContext, error) {
logger := logrus.New()
logger.Hooks.Add(&journalhook.JournalHook{})
// Setup log level
level, err := logrus.ParseLevel(cliContext.GlobalString("log-level"))
if err != nil {
return nil, cli.NewMultiError(cli.NewExitError("Invalid log level", 1), err)
}
logger.Level = level

if cliContext.GlobalBoolT("journald") {
logger.Hooks.Add(&journalhook.JournalHook{})
} else {
logger.Info("Disabling journald hook")
}
ret := &VPCContext{
Context: context.Background(),
CLIContext: cliContext,
Expand Down

0 comments on commit 222f918

Please sign in to comment.