-
Notifications
You must be signed in to change notification settings - Fork 493
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
algod: Write to stdout when config.LogSizeLimit is 0 or -o is passed to algod. #3903
Conversation
I'm not sure what the prior behavior would have been with LogSizeLimit:0. |
What do you think about having both? The The previous behavior here is basically a bug, all calls to log write an error to stdout:
|
I like the explicit option better. And yeah, it'd override because 'cyclic' doesn't make sense for stdout. |
@brianolson added a flag. Also converted algod to use cobra, but I can revert that part. |
99c903f
to
303231f
Compare
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.
Curious what the new algod -h
looks like with cobra. Old for comparison:
$ algod -h
Usage of algod:
-G Print genesis ID
-b Display the git branch behind the build
-c Display and release channel behind the build
-d string
Root Algorand daemon data path
-g string
Genesis configuration file
-l string
Override config.EndpointAddress (REST listening address) with ip:port
-p string
Override phonebook with peer ip:port (or semicolon separated list: ip:port;ip:port;ip:port...)
-s string
Telemetry Session GUID to use
-seed string
input to math/rand.Seed()
-t string
Override telemetry setting if supported (Use "true", "false", "0" or "1"
-v Display and write current build version and exit
-x Initialize the ledger and exit
cmd/algod/main.go
Outdated
command.Flags().StringVarP(&args.listenIP, "listenIP", "l", "", "Override config.EndpointAddress (REST listening address) with ip:port") | ||
command.Flags().StringVarP(&args.sessionGUID, "sessionGUID", "s", "", "Telemetry Session GUID to use") | ||
command.Flags().StringVarP(&args.telemetryOverride, "telemetryOverride", "t", "", `Override telemetry setting if supported (Use "true", "false", "0" or "1"`) | ||
command.Flags().StringVarP(&args.seed, "seed", "", "", "input to math/rand.Seed()") |
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 this needs to respond to "-seed" to be compatible with flag
. But every other flag
option only had the natural single letter -x and fits with -x/--xtralongname
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.
That might be a deal breaker here, that is the one part of the interface that had to change.
logWriter := logging.MakeCyclicFileWriter(liveLog, archive, cfg.LogSizeLimit, maxLogAge) | ||
|
||
var logWriter io.Writer | ||
if cfg.LogSizeLimit > 0 { |
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.
if args.logToStdout || cfg.LogSizeLimit <= 0 {
?
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.
The main function overrides cfg.LogSizeLimit
, so this is still the right condition.
This reverts commit 303231f.
I reverted the cobra changes, since you were curious this was the help output:
|
Codecov Report
@@ Coverage Diff @@
## master #3903 +/- ##
==========================================
- Coverage 50.09% 50.07% -0.03%
==========================================
Files 394 394
Lines 68456 68462 +6
==========================================
- Hits 34294 34279 -15
- Misses 30465 30482 +17
- Partials 3697 3701 +4
Continue to review full report at Codecov.
|
@@ -50,10 +50,11 @@ var versionCheck = flag.Bool("v", false, "Display and write current build versio | |||
var branchCheck = flag.Bool("b", false, "Display the git branch behind the build") | |||
var channelCheck = flag.Bool("c", false, "Display and release channel behind the build") | |||
var initAndExit = flag.Bool("x", false, "Initialize the ledger and exit") | |||
var logToStdout = flag.Bool("o", false, "Write to stdout instead of node.log by overriding config.LogSizeLimit to 0") |
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.
Oh, but now I'm imagining the convention -o foo
to log to file foo
and -o -
for stdout.
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.
doc would note "defaults to {data dir}/node.log"
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'd rather not add that feature unless there's a real reason that it would be useful. I kinda want to remove most of these flags, not sure they're actually used anymore.
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 guess picking a different letter would address that concern but all the good letters are taken already.
Summary
Add an implicit option to write log to stdout by setting LogSizeLimit to 0.
Test Plan
Tested manually.