v3 Started #160
Replies: 4 comments 3 replies
-
Hey! We're using It looks like the v3 branch hasn't seen too much activity since you wrote this post. Just wondering if you have a general idea when you plan to continue work on it? We'd love to upgrade Caddy to v3 once it's a bit more stable 😃 |
Beta Was this translation helpful? Give feedback.
-
This is exciting! We've been using lumberjack for years in Caddy. I see you're planning "periodic rotation (daily, etc.)" which sounds great. We got a lot of requests to rotate logs periodically by time instead of size, e.g.: caddyserver/caddy#1096 -- I seem to remember that feature has some technical difficulties though. Do you have a plan to overcome them? Another issue I recall is having multiple lumberjack.Loggers pointing at the same log file, but from within the same process: caddyserver/caddy#1363 -- we worked around this by pooling them, but I wonder if that's something that could be done under the hood? (I realize it's kind of a niche request, but just thought I'd mention it.) Also, we'd possibly be interested in multiple compression formats other than gzip. For example, zstd. |
Beta Was this translation helpful? Give feedback.
-
Oh, one other thing that's really important to us is the ability to stop a logger or clean up. When Caddy config is reloaded, the old logger should be stopped and the new logger will be started. This happens often during the lifetime of the process, as the logger config may change. For example, a Stop() or Close() method could be good, or even a context we can pass in that we would cancel should be sufficient! |
Beta Was this translation helpful? Give feedback.
-
Hey @natefinch |
Beta Was this translation helpful? Give feedback.
-
I started v3 of lumberjack a few days ago. 🎉
Alpha is Available
Already there's a sketch of how it'll look in the /v3 branch (which you can import as "github.com/natefinch/lumberjack/v3" and use
go get github.com/natefinch/lumberjack/v3@latest
to add it to your current project. There's a v3.0.0-alpha tag on that branch. All the old tests pass, but it's definitely alpha and you should expect the API to change.Backwards Compatibility is Paramount
My promise to you is that if you currently have an application using lumberjack v2, you'll be able to upgrade to v3, with v3 properly handling any v2 backup files etc. This will require that you configure v3 to mimic the behavior of v2, of course, but I'll make sure that's easy and well-documented.
New API
Lumberjack was one of the first Go libraries I wrote, and the fact that I almost immediately needed to release a v2 is kind of indicative of my immaturity with the language at the time. And the update to v3 mostly is about fixing the API mistakes I made in v2. 😆
For example, MaxSize of the file is just an int64 representing number of bytes (instead of integer number of megabytes), and MaxAge of a backup file is a time.Duration (rather than an integer number of days).
The new API will use a constructor function, so we can validate the configuration and the filename when you create it, rather than waiting for the first Write to find out if you typoed something.
New Features
I do plan to implement most of the feature requests that people have put forth that I previously shot down for being too prone to user error. Far be it from me to stop you from shooting yourself in the foot ;) ... but seriously, I can't always anticipate all the uses someone may have for the library, so I leave it up to you all to keep your feet out of the firing line.
I don't think there's any features that need removing from what exists in v2, so this list of TODOs should be considered purely additive to what's in v2:
Other Requests?
If you have any other requests, please feel free to respond here, rather than in issues, so we can all discuss them in one place. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions