Comments (3)
I've pushed bmoylan/lumberjack#1 which proposes a change to lumberjack for rotating after a max time
from witchcraft-go-server.
Just found natefinch/lumberjack#76 which sounds like he probably would not accept the contribution
from witchcraft-go-server.
Thanks for raising this issue!
Took a look at the PR, and one thing to note is that, as currently implemented, I don't think that it makes the guarantee that log files are rotated at least once per time interval since the rotation check happens on Write
. To make this guarantee, I do think that we'd need some goroutine that is running and would initiate rotation after the time period has elapsed. Although in general a running program will probably log to things like service logs at an interval where this isn't an issue, for logs that depend more on user actions (like event logs), this may be more of a possibility.
If at all possible, I would also like to avoid forking... Even though it's possible to fork or convert to an internal library here (since I don't think we expose the API externally at all), being on mainline would be nice.
What do you think of an implementation that would start a goroutine that does the file age comparison itself? I would imagine the high-level logic to be something like:
- When creating/initializing logger, look for output file and record creation time
- Start a timer that will fire at
creation time + configured max log file age
- When the timer fires, check creation time of output file
- If it is the same as before, then perform rotation and restart timer
- If it is different, then update timer to fire at
new creation time + configured max log file age
There is a small edge case here (we determine that file is old, decide to call "rotate", but a write that triggers size-based rotation happens right before the "rotate" call and thus we double-rotate and have a log file with just one line), but I think it's small enough to be acceptable (and even when it's hit, you don't lost data -- just have a file that is strangely small). If we really cared about this, then we could make a wrapper struct that implements the Logger interface (and does this goroutine) and then perform the locking at this higher level.
from witchcraft-go-server.
Related Issues (20)
- Runtime config refreshable produces zero value if cannot parse yaml
- pprof/goroutine returns 404 HOT 2
- Add a default health check for a sliding window of events HOT 1
- TestNewInflightLimitMiddleware test flakes
- Separate out trace sampling for application routes and management routes
- Allow selecting which go metrics you care about to emit HOT 4
- Default server/client metrics too verbose, no option to trim down HOT 10
- log canceled request as 499 instead of 500 HOT 8
- Ability to shutdown server with error HOT 3
- Reduce default trace rate to 1%
- 404s do not produce request logs
- Opt-in diagnostic log upon turning unhealthy HOT 5
- Improved panic logging
- Liveness endpoint should return non-empty JSON object
- Metric loggers should emit 0 value before regular value for certain metric types HOT 1
- connection metrics
- Encrypted values in configuration should be decoded while maintaining YAML structure
- RouteHandlerMiddleware unwieldy for endpoint-specific handling
- Missing pprof routes
- Library equivalent to Java's ManagedScheduledTask
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from witchcraft-go-server.