-
Notifications
You must be signed in to change notification settings - Fork 21
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
Log callback functions #137
Conversation
00cb59d
to
49304c2
Compare
func GenerateProof(dataDir string, challenge []byte, cfg config.Config, logger *zap.Logger, nonces uint, threads uint, powScrypt config.ScryptParams) (*shared.Proof, error) { | ||
if logger != nil { | ||
setLogCallback(logger) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that GenerateProof()
and others should accept logger
to be set for logging in the post-rs library. Only the first one will be set and remembered forever. While it's probably not a big deal in application code (as there will only be a single logger forever), in tests it will cause all logs to be recorded in the logger created for the first test that was executed probably causing them to appear in the wrong place (?).
I was imagining that there could be an exported function func ConfigureLogging(logger *zap.Logger)
documented to be idempotent, which should be called once by the application on its boot (starting phase of postcli or go-spacemesh).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a global logger in general is an issue. A ConfigureLogging
function is a workaround for the main application, but our approach to logging is not to have one global instance but (possible multiple) instances that are dependency-injected into the services.
With a global logger running tests in parallel becomes more difficult because logs from different tests are all printed to the same output concurrently and cannot easily be associated with the test they came from. This is why for instance zaptest.NewLog
takes an instance of testing.T
, so that the logs can be sorted to the tests they came from and go test
can print the outputs correctly.
EDIT: and tests can have different logging levels (e.g. tests where logs are irrelevant have a no-op logger, some have only info for dependent services and debug for the service at test, etc.)
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
## Motivation This integrates the new logging in `post` (spacemeshos/post#137) into `go-spacemesh`. ## Changes The logger needs to be passed thorough to some components of `post`. Do not merge before - [x] spacemeshos/post-rs#47 - [x] spacemeshos/post#137 - [x] #4390 are merged and released ## Test Plan Existing tests pass. ## TODO <!-- This section should be removed when all items are complete --> - [x] Explain motivation or link existing issue(s) - [x] Test changes and document test plan - [x] Update documentation as needed ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on) Co-authored-by: Bartosz Różański <[email protected]>
This integrates the changes from spacemeshos/post-rs#47 to allow
postrs
to log while being used ingo-spacemesh
.