Simplify log output on startup
This commit is contained in:
parent
bdd862e649
commit
b654198e3f
3 changed files with 6 additions and 8 deletions
|
|
@ -33,7 +33,7 @@ var (
|
|||
)
|
||||
|
||||
func doMigrations(connection_string string) error {
|
||||
log.Info().Str("dsn", connection_string).Msg("Connecting to database")
|
||||
log.Debug().Str("dsn", connection_string).Msg("Connecting to database")
|
||||
db, err := sql.Open("pgx", connection_string)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to open database connection: %w", err)
|
||||
|
|
@ -76,7 +76,7 @@ func doMigrations(connection_string string) error {
|
|||
}
|
||||
|
||||
func InitializeDatabase(ctx context.Context, uri string) error {
|
||||
log.Info().Str("dsn", uri).Msg("Connecting to database")
|
||||
log.Debug().Str("dsn", uri).Msg("Initializing database")
|
||||
needs, err := needsMigrations(uri)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to determine if migrations are needed: %w", err)
|
||||
|
|
@ -92,7 +92,7 @@ func InitializeDatabase(ctx context.Context, uri string) error {
|
|||
return fmt.Errorf("Failed to handle migrations: %w", err)
|
||||
}
|
||||
} else {
|
||||
log.Info().Msg("No database migrations necessary")
|
||||
log.Debug().Msg("No database migrations necessary")
|
||||
}
|
||||
|
||||
pgOnce.Do(func() {
|
||||
|
|
@ -111,7 +111,6 @@ func InitializeDatabase(ctx context.Context, uri string) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("Failed to get database current: %w", err)
|
||||
}
|
||||
log.Info().Str("database", current).Msg("Connected to database")
|
||||
err = prepareStatements(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to initialize prepared statements: %w", err)
|
||||
|
|
|
|||
5
main.go
5
main.go
|
|
@ -38,7 +38,6 @@ func main() {
|
|||
log.Error().Err(err).Msg("Failed to parse config")
|
||||
os.Exit(1)
|
||||
}
|
||||
log.Info().Msg("Starting...")
|
||||
|
||||
var prod = flag.Bool("prod", false, "Force into production mode")
|
||||
flag.Parse()
|
||||
|
|
@ -76,7 +75,7 @@ func main() {
|
|||
defer sentryWriter.Close()
|
||||
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||
log.Logger = log.Output(zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr}, sentryWriter))
|
||||
log.Logger = log.Output(zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr}, sentryWriter)).Level(zerolog.InfoLevel)
|
||||
|
||||
err = db.InitializeDatabase(context.TODO(), config.PGDSN)
|
||||
if err != nil {
|
||||
|
|
@ -131,7 +130,7 @@ func main() {
|
|||
hr.Map(config.DomainNidus, sr)
|
||||
r.Mount("/", hr)
|
||||
|
||||
log.Info().Str("report url", config.DomainRMO).Str("sync url", config.DomainNidus).Msg("Serving at URLs")
|
||||
log.Debug().Str("report url", config.DomainRMO).Str("sync url", config.DomainNidus).Msg("Serving at URLs")
|
||||
|
||||
// Start up background processes
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ func LoadTemplates() error {
|
|||
templateTXT: template_txt,
|
||||
}
|
||||
templateByID[template_id] = &built
|
||||
log.Info().Int32("id", template_id).Str("name", name).Msg("Added template to cache")
|
||||
//log.Debug().Int32("id", template_id).Str("name", name).Msg("Added template to cache")
|
||||
}
|
||||
templateInitialID, err = loadTemplateID(ctx, tx, enums.CommsMessagetypeemailInitialContact)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue