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

Multiple output files doesn't use the correct "SetFlags" #29

Open
sandebains opened this issue Sep 21, 2019 · 0 comments
Open

Multiple output files doesn't use the correct "SetFlags" #29

sandebains opened this issue Sep 21, 2019 · 0 comments

Comments

@sandebains
Copy link

I'm using the below configuration where multiple files are in use for writing logs. However with the SetFlags options in place, I noticed that only first file adhere to the settings. Rest of the files fall back to generic option where the "code line numbers" are being printed.

Code Snippet (Initializing files and logger):

lf2, err := os.OpenFile("log/server.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0660)
if err != nil {
	logger.Fatalf("Failed to open log file: %v", err)
}
defer lf2.Close()
lf3, err := os.OpenFile("log/auth.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0660)
if err != nil {
	logger.Fatalf("Failed to open log file: %v", err)
}
defer lf3.Close()
glogger = logger.Init("Websockets Logger", false, false, lf)
defer glogger.Close()

Ologger = logger.Init("General Logger", false, false, lf2)
defer Ologger.Close()

userlogger = logger.Init("Authentication Logger", false, false, lf3)
defer userlogger.Close()

Code Snippet: (Initializing logger flags)
logger.SetFlags(log.LstdFlags | log.LUTC)

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

No branches or pull requests

1 participant