-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
Native log broken for package consumers #28738
Comments
I would like to fix this. I could reproduce this bug. Can someone give me some context about this issue? :) |
Figuring out what happened and why is the large part of fixing any bug (mostly). Go for it, @0x0elliot ! |
I will then! Let me get done with another PR I am working on and get to this. Kindly assign :) |
This seems like intended behaviour @synthmeat https://github.com/ethereum/go-ethereum/releases/tag/v1.13.6 in here it clearly states:
and... @namiloh This seems intended. Is there still some optimisation you would want me to make to help out users? |
@0x0elliot But I'm clearly not using |
@synthmeat Right! I missed that. Let me look deeper. |
Interesting observation: package main
import (
"log/slog"
"os"
"fmt"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
)
func main() {
_, err := ethclient.Dial("https://mainnet.infura.io")
if err != nil {
fmt.Println("error")
}
slog.Info("(1) hello world")
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) // recommendation made
slog.Info("(2) hello world")
} That's extremely interesting. It is happening because of: Line 13 in 28e7371
where init() is called. Same observation is made when I just import package main
import (
"log/slog"
"os"
// "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
)
func main() {
slog.Info("(1) hello world")
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true)))
slog.Info("(2) hello world")
} |
To summarise it @synthmeat, Technically, you're not using "github.com/ethereum/go-ethereum/log" but ethereum's ethclient uses it. @namiloh since this is "intended behaviour", I guess, I can update documentation for it (just by this issue existing as well, Life becomes easy for those trying to figure out what's making their logs disappear) More here: #28558 (comment)
|
This behaviour seems wrong to me, I don't see why we should initiate slog with a default discard-handler. We could just leave it be whatever it already is. |
This issue is about package |
I assume golang authors decided to route log to slog...? |
i went ahead and used slog (and forgot to remove it while experimenting around) because log and slog show similar behaviour in this context! |
The issue happens because we call |
@fjl where will this overriding be done then next, if we would still need to do that? (i can figure this on my own soon enough when i am on keyboard) |
No we would just remove the init, not replace. |
well, i can make a small PR for that if it's that simple :) @namiloh |
Fixed by #28747 |
It should be fixed on the master branch. |
v1.13.6
introduced issue where it breakslog
usage for package consumers.Minimal code to reproduce, where expectation is to print anything to stderr. What happens is that it doesn't print anything at all. (
fmt
to either stdout or stderr works fine.)main.go
go.mod
The text was updated successfully, but these errors were encountered: