komuw / ong

ong, is a Go http toolkit.
MIT License
16 stars 4 forks source link

ong/log: make maxSize configurable at runtime #426

Closed komuw closed 2 weeks ago

komuw commented 3 months ago

https://github.com/komuw/ong/blob/ca6f5d216e6f974d33976c8b37bd4c20f4273d39/log/log.go#L52

This would allow people to increase/decrease the size of log buffer at runtime. Imagine if your app is getting lots of errors and you want to include longer duration context. Right now you would have to re-deploy with a bigger maxSize, with this proposal; you could just dynamically set it.

We just need to make maxSize be a type that is based off atomic.Int64, similar to slog.LevelVar; https://github.com/golang/go/blob/go1.22.2/src/log/slog/level.go#L152-L160
https://github.com/FiloSottile/sunlight/blob/dd12c8afecd6e57d9f6d70abf4d121e52f4f3d8b/cmd/sunlight/main.go#L199-L215

Also see; https://github.com/komuw/ong/issues/423

komuw commented 2 weeks ago

No.