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

How to log to multiple files? #5

Open
smjure opened this issue Dec 16, 2022 · 0 comments
Open

How to log to multiple files? #5

smjure opened this issue Dec 16, 2022 · 0 comments

Comments

@smjure
Copy link

smjure commented Dec 16, 2022

It's really awesome logger, the fastest I've tested for my usecase. However, I'd like to write to multiple files, but I am not sure if that's even possible. Something like this:

nanoLog1, err := os.OpenFile("file1.log", os.O_CREATE|os.O_WRONLY, 0644)
nanolog.SetWriter(nanoLog1)
h1:= nanolog.AddLogger("%s")

nanoLog2, err := os.OpenFile("file2.log", os.O_CREATE|os.O_WRONLY, 0644)
nanolog.SetWriter(nanoLog2)
h2 := nanolog.AddLogger("%s")

defer nanolog.Flush()
	
// --- Logging
nanolog.Log(h1, msg1) 
nanolog.Log(h2, msg2) 

All is logged to the last file. Would it be somehow possible to write to multiple log files? Thank you 🙏🏻

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