Skip to content

Commit

Permalink
feat(#105): actually support json logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Jumpy-Squirrel committed Dec 22, 2023
1 parent fdafbda commit d86d1b8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var errHelpRequested = errors.New("help text was requested")
var (
showHelp bool
migrate bool
ecsJsonLogging bool
configFilePath string
)

Expand All @@ -42,20 +43,21 @@ const (
func main() {
ctx, cancel := context.WithCancel(context.Background())

logging.SetupLogging("payment-service", false)
logger := logging.NewLogger()
err := parseArgs()

sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
logging.SetupLogging("payment-service", ecsJsonLogging)
logger := logging.NewLogger()

logger.Debug("parsing command line flags")
if err := parseArgs(logger); err != nil {
if err != nil {
if !errors.Is(err, errHelpRequested) {
logger.Fatal("%v", err)
}
os.Exit(0)
}

sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)

logger.Debug("loading configuration")
conf, err := readConfigFile(logger)
if err != nil {
Expand Down Expand Up @@ -129,10 +131,11 @@ func main() {
}
}

func parseArgs(logger logging.Logger) error {
func parseArgs() error {
flag.BoolVar(&showHelp, "h", false, "Displays the help text")
flag.StringVar(&configFilePath, "config", "", "The path to a configuration file")
flag.BoolVar(&migrate, "migrate-database", false, "Performs database migrations before the service starts")
flag.BoolVar(&ecsJsonLogging, "ecs-json-logging", false, "Enable json logging")

flag.Parse()

Expand Down

0 comments on commit d86d1b8

Please sign in to comment.