Skip to content

Rotation zap log#5231

Closed
tuyenpthust wants to merge 12 commits intotemporalio:mainfrom
tuyenpthust:rotation-zap-log
Closed

Rotation zap log#5231
tuyenpthust wants to merge 12 commits intotemporalio:mainfrom
tuyenpthust:rotation-zap-log

Conversation

@tuyenpthust
Copy link
Contributor

What changed?

add rotation zaplog based on file size

Why?

Currently all log are written in 1 file, it's easier to maintain, debug, backup if the log file is rotated

How did you test it?

Test locally and unittest

@tuyenpthust tuyenpthust requested a review from a team as a code owner December 14, 2023 10:04
logger, _ := config.Build()
var logger *zap.Logger
if cfg.EnableRotation && len(cfg.OutputFile) > 0 {
core, _ := rotationZapCore(cfg, config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check and respond to this error, please don't swallow it

}

func newEncoder(name string, encoderConfig zapcore.EncoderConfig) (zapcore.Encoder, error) {
if name == "console" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind replacing these with an enum containing something like ConsoleEncoding and JSONEncoding in the few places we use it?

tuyenpthust and others added 4 commits April 9, 2024 07:12

func BenchmarkZapLoggerWithFields(b *testing.B) {
zLogger := buildZapLogger(Config{Level: "info"}, false)
zLogger, _ := buildZapLogger(Config{Level: "info"}, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check these errors and fail the benchmarks if these fail. It will help prevent problems when this code changes in the future

Copy link
Contributor

@tdeebswihart tdeebswihart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good over all but this PR should not change the version of the API repo used.

assert.Less(t, currentFile.Size(), int64(1024*1024))
}

func TestNoRotationLogger(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about

Suggested change
func TestNoRotationLogger(t *testing.T) {
func TestLogger_FilesArentRotated_WhenDisabled(t *testing.T) {

That's cleared about what you're testing (and the above could be TestLogger_FilesAreRotated_WhenEnabled or something)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be updated as part of your PR. Please either rebase on main or check out the same version of the submodule as is on main

Copy link
Contributor

@dnr dnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the contribution, but I'm wondering if this is really something that we want to build into the server, adding complexity and taking on yet another dependency.

In general modern infrastructure is moving in the direction of having server processes log to stdout, and having external systems accept logs and slice and dice and ship them in various ways, specifically so that every server doesn't have to have a full range of configuration options and log processing can be consolidated across services. This is true of both single-machine process managers like docker and systemd and of course distributed systems like k8s as well.

In that light, this change feels like a bit of a regression in infrastructure management. Could you provide a stronger justification for why this should go in the server itself?

@github-actions
Copy link

This PR was marked as stale. Please update or close it.

@github-actions github-actions bot added the stale label Oct 11, 2024
@github-actions github-actions bot removed the stale label Nov 30, 2024
@github-actions
Copy link

github-actions bot commented Apr 6, 2025

This PR was marked as stale. Please update or close it.

@github-actions github-actions bot added the stale label Apr 6, 2025
@tuyenpthust tuyenpthust deleted the rotation-zap-log branch April 12, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants