Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple config loading & log initialization #471

Merged
merged 2 commits into from
May 23, 2024

Conversation

jholdstock
Copy link
Member

@jholdstock jholdstock commented May 20, 2024

Loading config and preparing loggers are two separate concepts which should be handled individually. Nesting one inside the other makes little sense and complicates reusing the code.

@jholdstock jholdstock changed the title database: Remove log param from CreateNew. Decouple config loading & log initialization May 20, 2024
@jholdstock jholdstock force-pushed the rm-db-log branch 3 times, most recently from d5e569f to f11b7e8 Compare May 21, 2024 07:59
@@ -425,12 +412,14 @@ func loadConfig() (*vspdConfig, error) {
}

// Create new database.
err = database.CreateNew(cfg.dbPath, cfg.FeeXPub, cfg.logger(" DB"))
fmt.Printf("Initializing new database at %s\n", cfg.dbPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now these won't be in the logs.

@@ -165,8 +160,6 @@ func CreateNew(dbFile, feeXPub string, log slog.Logger) error {
return err
}

log.Info("Database initialized")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a log you wouldn't want to lose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per #465, creating the database will soon be in a new dedicated binary, so this is somewhat temporary/irrelevant.

This logger did not write any useful information and all errors
generated by the func are already returned to the caller for logging.
Loading config and preparing loggers are two separate concepts which
should be handled individually. Nesting one inside the other makes
little sense and complicates reusing the code.
@jholdstock jholdstock merged commit 6e558fb into decred:master May 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants