feat: add --log-timestamp-format to configure log timestamp layout - #167
Merged
Merged
Conversation
Log timestamps are hard-coded to RFC3339Nano in both logrus formatters. Operators feeding logs into analytics pipelines need to match an existing timestamp convention, so this makes the format configurable as a Go time layout via --log-timestamp-format. Empty keeps the current default, so behaviour is unchanged unless the flag is set. The format is stored on the logger and the formatter is rebuilt through a shared applyFormatter, so the configured layout survives toggling --log-as-json. The option is applied via a type assertion in ApplyOptionsToLoggers rather than by widening the exported Logger interface, keeping this a non-breaking change for external implementers. Both in-tree implementations provide the method. This recreates dapr#164 with fresh authorship so the DCO sign-off matches the commit author; the implementation and tests are Mirel's work. Co-authored-by: Mirel <15373565+MyMirelHub@users.noreply.github.com> Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
nelson-parente
force-pushed
the
feat/log-timestamp-format
branch
from
August 31, 2026 10:29
767d120 to
3e7faf8
Compare
nelson-parente
marked this pull request as ready for review
September 1, 2026 09:21
javier-aliaga
approved these changes
Sep 1, 2026
JoshVanL
requested changes
Sep 1, 2026
JoshVanL
approved these changes
Sep 1, 2026
nelson-parente
added a commit
to nelson-parente/kit
that referenced
this pull request
Sep 2, 2026
Rebase onto main after dapr#167 merged: the exact-flag-set test failed as designed on the new flag; register it in the expected set. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
nelson-parente
added a commit
to nelson-parente/kit
that referenced
this pull request
Sep 2, 2026
Rebase onto main after dapr#167 merged: the exact-flag-set test failed as designed on the new flag; register it in the expected set. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
JoshVanL
pushed a commit
that referenced
this pull request
Sep 3, 2026
…166) * feat: add --log-file-tee to write logs to both file and console When --log-file is set the logger currently replaces the console writer, so logs stop appearing in kubectl logs. --log-file-tee keeps both destinations via io.MultiWriter. The console writer is listed first because io.MultiWriter stops at the first failed writer: this way console output survives file write failures such as a full disk. Default is false, so existing behaviour is unchanged. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: add size/age-based rotation for --log-file output --log-file opens the file in append mode and never rolls it, so long-lived components grow it without bound. This adds rotation via lumberjack behind four new flags: --log-file-max-size megabytes before rotation --log-file-max-backups rotated files to keep --log-file-max-age days to retain rotated files --log-file-compress gzip rotated files When none of them is set the writer stays a plain append-mode *os.File, so existing behaviour is byte-for-byte unchanged. The three numeric options are string-typed and parsed at apply time so that AttachCmdFlags keeps its (stringVar, boolVar) signature. That keeps the kit bump non-breaking and surfaces the flags on every binary with no caller changes. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix(test): call t.TempDir before registering the tee cleanup t.Cleanup runs LIFO. The tee tests registered their cleanup before calling t.TempDir, so TempDir's RemoveAll ran first — while the log file was still open — and Windows cannot delete an open file: TempDir RemoveAll cleanup: unlinkat ...\dapr.log: The process cannot access the file because it is being used by another process. Calling t.TempDir first registers its cleanup first, so it runs last, after the cleanup that closes the file. The rotation test already had this ordering, which is why only the two tee tests failed. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * test: cover rotation behaviour, flag registration and tee+rotation The existing rotation tests asserted only that the lumberjack struct was populated correctly. That would still pass if the rotating writer were never installed as the log output, or if MaxSize were interpreted in the wrong unit, so it verified configuration rather than behaviour. Adds three gaps: - TestFileRotationActuallyRotates drives ~3MB through the configured logger with max-size=1MB and asserts on disk that an archive appeared and the active file was rolled. Only size-based rotation is asserted: lumberjack rotates synchronously on the write that exceeds MaxSize, whereas compression and MaxBackups pruning run on a background goroutine and would make the assertion timing-dependent. - TestOptions/registers_the_exact_set_of_log_flags asserts the full registered flag set rather than spot-checking names. Flag names become D3E chart annotations, so a rename is a breaking change for anyone who has already set them; this makes that fail deliberately rather than silently. - TestTeeWithRotation covers file output that both rotates and tees, which is the combination actually configured in the field. Nothing previously exercised the MultiWriter-wrapping-lumberjack composition. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: warn on inert file options; keep file permissions stable under rotation Two behaviours surfaced by review: 1. Setting --log-file-tee or any rotation flag without --log-file was a silent no-op. Now it logs a warning through a dapr.kit.logger logger. Warn rather than fail: an error here would turn a harmless misconfiguration into a startup failure for every binary that attaches these flags. The logger is fetched at the top of ApplyOptionsToLoggers, before the registry snapshot, so it always follows the configured format, level and output for that apply. 2. lumberjack creates missing log files as 0600 (and preserves the mode of existing ones), where the non-rotating path creates 0644. Enabling rotation would therefore silently change new log file permissions and break log shippers tailing the file as a non-owner user. newFileWriter now pre-creates the file with the same flags and mode as the plain path, so permissions are identical whether or not rotation is enabled; rotated archives and post-rotation files inherit that mode. The permission test compares the plain and rotating paths against each other rather than asserting an absolute mode, so it is immune to umask and Windows permission semantics. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * refactor: parse rotation values with ParseUint Review feedback: the rotation values are semantically unsigned, so parse them with strconv.ParseUint (bit size 31 keeps the int conversion safe on 32-bit platforms) instead of Atoi plus a sign check. The struct fields stay string-typed because they bind through AttachCmdFlags(stringVar, boolVar); widening that signature would break every existing caller. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * test: include log-timestamp-format in the exact flag set Rebase onto main after #167 merged: the exact-flag-set test failed as designed on the new flag; register it in the expected set. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * refactor: typed optional fields behind separate flag receivers; compression enum Review feedback: the optional fields are now properly typed and unexported — *uint rotation limits (nil = not provided) and a none|gzip compression enum — with the CLI flags attached to separate unexported string receivers that validate() parses at apply time, mirroring the pattern in dapr/dapr cmd/daprd/options. AttachCmdFlags keeps its (stringVar, boolVar) signature, so no caller changes anywhere. --log-file-compress (bool) becomes --log-file-compression=none|gzip, which leaves room for other codecs without a flag break. Invalid values fail validation before any logger is mutated. Behaviour is unchanged: an explicit 0 still disables the corresponding limit, and with no rotation engaged the writer stays the plain append-mode file. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: replace --log-file-tee with a --log-outputs destination list Review feedback: rather than a tee bool, log destinations are a list. --log-outputs takes a comma-separated list of "stdout", "stderr", or file paths; --log-file merges into that list, so both flags compose and existing behaviour is unchanged. The previous tee semantics are expressed as --log-outputs=stdout,/path/to/file. Destinations are deduplicated (two writers on one path would double every line and corrupt rotation) and console destinations order before files, so io.MultiWriter keeps console output alive when file writes start failing. Rotation and compression options apply to every file destination. The inert-option warning now keys on "no file destination configured" rather than --log-file specifically. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix: align rotation usage strings with the destination model; test the open-failure unwind Pre-merge review findings: - The three rotation usage strings still said "No effect without --log-file", but the actual gating (and the warning) treat a file entry in --log-outputs as an equally valid destination. All four file-option usage strings now say "a file destination". - The mid-list open-failure unwind in setLogOutput (close already-opened files, leave every logger on its previous output) had no test. Added one that applies destinations [stdout, <directory>] and asserts the apply errors while loggers keep writing to their previous output. - File paths are normalized with filepath.Clean before deduplication, so the same file spelled differently (./x.log vs x.log) resolves to a single writer instead of two writers corrupting rotation. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix(test): compare destinations against the filepath.Clean form File paths in the destination list pass through filepath.Clean, whose separator differs by OS. The ordering/dedupe test hardcoded the Unix form and failed on Windows (\var\log\a.log vs /var/log/a.log); compare against the cleaned form so the assertion is platform-correct. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> --------- Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
nelson-parente
added a commit
to nelson-parente/kit
that referenced
this pull request
Sep 3, 2026
…apr#167) Log timestamps are hard-coded to RFC3339Nano in both logrus formatters. Operators feeding logs into analytics pipelines need to match an existing timestamp convention, so this makes the format configurable as a Go time layout via --log-timestamp-format. Empty keeps the current default, so behaviour is unchanged unless the flag is set. The format is stored on the logger and the formatter is rebuilt through a shared applyFormatter, so the configured layout survives toggling --log-as-json. The option is applied via a type assertion in ApplyOptionsToLoggers rather than by widening the exported Logger interface, keeping this a non-breaking change for external implementers. Both in-tree implementations provide the method. This recreates dapr#164 with fresh authorship so the DCO sign-off matches the commit author; the implementation and tests are Mirel's work. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> Co-authored-by: Mirel <15373565+MyMirelHub@users.noreply.github.com>
nelson-parente
added a commit
to nelson-parente/kit
that referenced
this pull request
Sep 3, 2026
…apr#166) * feat: add --log-file-tee to write logs to both file and console When --log-file is set the logger currently replaces the console writer, so logs stop appearing in kubectl logs. --log-file-tee keeps both destinations via io.MultiWriter. The console writer is listed first because io.MultiWriter stops at the first failed writer: this way console output survives file write failures such as a full disk. Default is false, so existing behaviour is unchanged. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: add size/age-based rotation for --log-file output --log-file opens the file in append mode and never rolls it, so long-lived components grow it without bound. This adds rotation via lumberjack behind four new flags: --log-file-max-size megabytes before rotation --log-file-max-backups rotated files to keep --log-file-max-age days to retain rotated files --log-file-compress gzip rotated files When none of them is set the writer stays a plain append-mode *os.File, so existing behaviour is byte-for-byte unchanged. The three numeric options are string-typed and parsed at apply time so that AttachCmdFlags keeps its (stringVar, boolVar) signature. That keeps the kit bump non-breaking and surfaces the flags on every binary with no caller changes. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix(test): call t.TempDir before registering the tee cleanup t.Cleanup runs LIFO. The tee tests registered their cleanup before calling t.TempDir, so TempDir's RemoveAll ran first — while the log file was still open — and Windows cannot delete an open file: TempDir RemoveAll cleanup: unlinkat ...\dapr.log: The process cannot access the file because it is being used by another process. Calling t.TempDir first registers its cleanup first, so it runs last, after the cleanup that closes the file. The rotation test already had this ordering, which is why only the two tee tests failed. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * test: cover rotation behaviour, flag registration and tee+rotation The existing rotation tests asserted only that the lumberjack struct was populated correctly. That would still pass if the rotating writer were never installed as the log output, or if MaxSize were interpreted in the wrong unit, so it verified configuration rather than behaviour. Adds three gaps: - TestFileRotationActuallyRotates drives ~3MB through the configured logger with max-size=1MB and asserts on disk that an archive appeared and the active file was rolled. Only size-based rotation is asserted: lumberjack rotates synchronously on the write that exceeds MaxSize, whereas compression and MaxBackups pruning run on a background goroutine and would make the assertion timing-dependent. - TestOptions/registers_the_exact_set_of_log_flags asserts the full registered flag set rather than spot-checking names. Flag names become D3E chart annotations, so a rename is a breaking change for anyone who has already set them; this makes that fail deliberately rather than silently. - TestTeeWithRotation covers file output that both rotates and tees, which is the combination actually configured in the field. Nothing previously exercised the MultiWriter-wrapping-lumberjack composition. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: warn on inert file options; keep file permissions stable under rotation Two behaviours surfaced by review: 1. Setting --log-file-tee or any rotation flag without --log-file was a silent no-op. Now it logs a warning through a dapr.kit.logger logger. Warn rather than fail: an error here would turn a harmless misconfiguration into a startup failure for every binary that attaches these flags. The logger is fetched at the top of ApplyOptionsToLoggers, before the registry snapshot, so it always follows the configured format, level and output for that apply. 2. lumberjack creates missing log files as 0600 (and preserves the mode of existing ones), where the non-rotating path creates 0644. Enabling rotation would therefore silently change new log file permissions and break log shippers tailing the file as a non-owner user. newFileWriter now pre-creates the file with the same flags and mode as the plain path, so permissions are identical whether or not rotation is enabled; rotated archives and post-rotation files inherit that mode. The permission test compares the plain and rotating paths against each other rather than asserting an absolute mode, so it is immune to umask and Windows permission semantics. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * refactor: parse rotation values with ParseUint Review feedback: the rotation values are semantically unsigned, so parse them with strconv.ParseUint (bit size 31 keeps the int conversion safe on 32-bit platforms) instead of Atoi plus a sign check. The struct fields stay string-typed because they bind through AttachCmdFlags(stringVar, boolVar); widening that signature would break every existing caller. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * test: include log-timestamp-format in the exact flag set Rebase onto main after dapr#167 merged: the exact-flag-set test failed as designed on the new flag; register it in the expected set. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * refactor: typed optional fields behind separate flag receivers; compression enum Review feedback: the optional fields are now properly typed and unexported — *uint rotation limits (nil = not provided) and a none|gzip compression enum — with the CLI flags attached to separate unexported string receivers that validate() parses at apply time, mirroring the pattern in dapr/dapr cmd/daprd/options. AttachCmdFlags keeps its (stringVar, boolVar) signature, so no caller changes anywhere. --log-file-compress (bool) becomes --log-file-compression=none|gzip, which leaves room for other codecs without a flag break. Invalid values fail validation before any logger is mutated. Behaviour is unchanged: an explicit 0 still disables the corresponding limit, and with no rotation engaged the writer stays the plain append-mode file. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: replace --log-file-tee with a --log-outputs destination list Review feedback: rather than a tee bool, log destinations are a list. --log-outputs takes a comma-separated list of "stdout", "stderr", or file paths; --log-file merges into that list, so both flags compose and existing behaviour is unchanged. The previous tee semantics are expressed as --log-outputs=stdout,/path/to/file. Destinations are deduplicated (two writers on one path would double every line and corrupt rotation) and console destinations order before files, so io.MultiWriter keeps console output alive when file writes start failing. Rotation and compression options apply to every file destination. The inert-option warning now keys on "no file destination configured" rather than --log-file specifically. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix: align rotation usage strings with the destination model; test the open-failure unwind Pre-merge review findings: - The three rotation usage strings still said "No effect without --log-file", but the actual gating (and the warning) treat a file entry in --log-outputs as an equally valid destination. All four file-option usage strings now say "a file destination". - The mid-list open-failure unwind in setLogOutput (close already-opened files, leave every logger on its previous output) had no test. Added one that applies destinations [stdout, <directory>] and asserts the apply errors while loggers keep writing to their previous output. - File paths are normalized with filepath.Clean before deduplication, so the same file spelled differently (./x.log vs x.log) resolves to a single writer instead of two writers corrupting rotation. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix(test): compare destinations against the filepath.Clean form File paths in the destination list pass through filepath.Clean, whose separator differs by OS. The ordering/dedupe test hardcoded the Unix form and failed on Windows (\var\log\a.log vs /var/log/a.log); compare against the cleaned form so the assertion is platform-correct. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> --------- Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
nelson-parente
added a commit
to nelson-parente/kit
that referenced
this pull request
Sep 3, 2026
…apr#167) Log timestamps are hard-coded to RFC3339Nano in both logrus formatters. Operators feeding logs into analytics pipelines need to match an existing timestamp convention, so this makes the format configurable as a Go time layout via --log-timestamp-format. Empty keeps the current default, so behaviour is unchanged unless the flag is set. The format is stored on the logger and the formatter is rebuilt through a shared applyFormatter, so the configured layout survives toggling --log-as-json. The option is applied via a type assertion in ApplyOptionsToLoggers rather than by widening the exported Logger interface, keeping this a non-breaking change for external implementers. Both in-tree implementations provide the method. This recreates dapr#164 with fresh authorship so the DCO sign-off matches the commit author; the implementation and tests are Mirel's work. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> Co-authored-by: Mirel <15373565+MyMirelHub@users.noreply.github.com>
nelson-parente
added a commit
to nelson-parente/kit
that referenced
this pull request
Sep 3, 2026
…apr#166) * feat: add --log-file-tee to write logs to both file and console When --log-file is set the logger currently replaces the console writer, so logs stop appearing in kubectl logs. --log-file-tee keeps both destinations via io.MultiWriter. The console writer is listed first because io.MultiWriter stops at the first failed writer: this way console output survives file write failures such as a full disk. Default is false, so existing behaviour is unchanged. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: add size/age-based rotation for --log-file output --log-file opens the file in append mode and never rolls it, so long-lived components grow it without bound. This adds rotation via lumberjack behind four new flags: --log-file-max-size megabytes before rotation --log-file-max-backups rotated files to keep --log-file-max-age days to retain rotated files --log-file-compress gzip rotated files When none of them is set the writer stays a plain append-mode *os.File, so existing behaviour is byte-for-byte unchanged. The three numeric options are string-typed and parsed at apply time so that AttachCmdFlags keeps its (stringVar, boolVar) signature. That keeps the kit bump non-breaking and surfaces the flags on every binary with no caller changes. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix(test): call t.TempDir before registering the tee cleanup t.Cleanup runs LIFO. The tee tests registered their cleanup before calling t.TempDir, so TempDir's RemoveAll ran first — while the log file was still open — and Windows cannot delete an open file: TempDir RemoveAll cleanup: unlinkat ...\dapr.log: The process cannot access the file because it is being used by another process. Calling t.TempDir first registers its cleanup first, so it runs last, after the cleanup that closes the file. The rotation test already had this ordering, which is why only the two tee tests failed. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * test: cover rotation behaviour, flag registration and tee+rotation The existing rotation tests asserted only that the lumberjack struct was populated correctly. That would still pass if the rotating writer were never installed as the log output, or if MaxSize were interpreted in the wrong unit, so it verified configuration rather than behaviour. Adds three gaps: - TestFileRotationActuallyRotates drives ~3MB through the configured logger with max-size=1MB and asserts on disk that an archive appeared and the active file was rolled. Only size-based rotation is asserted: lumberjack rotates synchronously on the write that exceeds MaxSize, whereas compression and MaxBackups pruning run on a background goroutine and would make the assertion timing-dependent. - TestOptions/registers_the_exact_set_of_log_flags asserts the full registered flag set rather than spot-checking names. Flag names become D3E chart annotations, so a rename is a breaking change for anyone who has already set them; this makes that fail deliberately rather than silently. - TestTeeWithRotation covers file output that both rotates and tees, which is the combination actually configured in the field. Nothing previously exercised the MultiWriter-wrapping-lumberjack composition. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: warn on inert file options; keep file permissions stable under rotation Two behaviours surfaced by review: 1. Setting --log-file-tee or any rotation flag without --log-file was a silent no-op. Now it logs a warning through a dapr.kit.logger logger. Warn rather than fail: an error here would turn a harmless misconfiguration into a startup failure for every binary that attaches these flags. The logger is fetched at the top of ApplyOptionsToLoggers, before the registry snapshot, so it always follows the configured format, level and output for that apply. 2. lumberjack creates missing log files as 0600 (and preserves the mode of existing ones), where the non-rotating path creates 0644. Enabling rotation would therefore silently change new log file permissions and break log shippers tailing the file as a non-owner user. newFileWriter now pre-creates the file with the same flags and mode as the plain path, so permissions are identical whether or not rotation is enabled; rotated archives and post-rotation files inherit that mode. The permission test compares the plain and rotating paths against each other rather than asserting an absolute mode, so it is immune to umask and Windows permission semantics. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * refactor: parse rotation values with ParseUint Review feedback: the rotation values are semantically unsigned, so parse them with strconv.ParseUint (bit size 31 keeps the int conversion safe on 32-bit platforms) instead of Atoi plus a sign check. The struct fields stay string-typed because they bind through AttachCmdFlags(stringVar, boolVar); widening that signature would break every existing caller. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * test: include log-timestamp-format in the exact flag set Rebase onto main after dapr#167 merged: the exact-flag-set test failed as designed on the new flag; register it in the expected set. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * refactor: typed optional fields behind separate flag receivers; compression enum Review feedback: the optional fields are now properly typed and unexported — *uint rotation limits (nil = not provided) and a none|gzip compression enum — with the CLI flags attached to separate unexported string receivers that validate() parses at apply time, mirroring the pattern in dapr/dapr cmd/daprd/options. AttachCmdFlags keeps its (stringVar, boolVar) signature, so no caller changes anywhere. --log-file-compress (bool) becomes --log-file-compression=none|gzip, which leaves room for other codecs without a flag break. Invalid values fail validation before any logger is mutated. Behaviour is unchanged: an explicit 0 still disables the corresponding limit, and with no rotation engaged the writer stays the plain append-mode file. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * feat: replace --log-file-tee with a --log-outputs destination list Review feedback: rather than a tee bool, log destinations are a list. --log-outputs takes a comma-separated list of "stdout", "stderr", or file paths; --log-file merges into that list, so both flags compose and existing behaviour is unchanged. The previous tee semantics are expressed as --log-outputs=stdout,/path/to/file. Destinations are deduplicated (two writers on one path would double every line and corrupt rotation) and console destinations order before files, so io.MultiWriter keeps console output alive when file writes start failing. Rotation and compression options apply to every file destination. The inert-option warning now keys on "no file destination configured" rather than --log-file specifically. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix: align rotation usage strings with the destination model; test the open-failure unwind Pre-merge review findings: - The three rotation usage strings still said "No effect without --log-file", but the actual gating (and the warning) treat a file entry in --log-outputs as an equally valid destination. All four file-option usage strings now say "a file destination". - The mid-list open-failure unwind in setLogOutput (close already-opened files, leave every logger on its previous output) had no test. Added one that applies destinations [stdout, <directory>] and asserts the apply errors while loggers keep writing to their previous output. - File paths are normalized with filepath.Clean before deduplication, so the same file spelled differently (./x.log vs x.log) resolves to a single writer instead of two writers corrupting rotation. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> * fix(test): compare destinations against the filepath.Clean form File paths in the destination list pass through filepath.Clean, whose separator differs by OS. The ordering/dedupe test hardcoded the Unix form and failed on Windows (\var\log\a.log vs /var/log/a.log); compare against the cleaned form so the assertion is platform-correct. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> --------- Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
--log-timestamp-formatto configure the log timestamp as a Go time layout across every component that attacheslogger.Optionsflags. Empty keeps the current default (RFC3339 with nanoseconds), so behaviour is unchanged unless the flag is set.The exported
Loggerinterface is untouched.SetTimestampFormatexists as a concrete method on both in-tree implementations, andApplyOptionsToLoggersapplies it via a type assertion:A code search across dapr/dapr, components-contrib, dapr/cli, go-sdk and durabletask-go found no external implementers of
Logger, so widening the interface would likely be safe — but the assertion gets identical behaviour with zero breaking-change surface, and the interface already carries a//nolint: interfacebloat. Happy to switch to the interface method if that's preferred.Two
golangci-lintfindings in the original diff fixed (funcorderon the newapplyFormatter, onewslspacing in the tests).For the record: this PR's first CI run failed
Build linux_amd64onTestFSWatcher/should_debounce_burst_of_writes_on_same_file— a timing-sensitive test in a package this change does not touch — so #164's month-old failure on the same job was quite possibly the same pre-existing flake rather than anything in the diff.Design
The format is stored on the logger and the formatter is rebuilt through a shared
applyFormatter, so the configured layout survives toggling--log-as-jsonin either direction (covered by a test). An empty format resets to the default.Docs note for the flag reference: users coming from Java express formats as
SimpleDateFormatpatterns — the mapping is e.g.yyyy/MM/dd HH:mm:ss.SSS→2006/01/02 15:04:05.000.Relationship to #166
Independent, but both add flags in
AttachCmdFlags, so whichever merges second will have a trivial adjacent-line conflict; #166 also carries a test asserting the exact registered flag set, which will wantlog-timestamp-formatadded when both are in.Test plan
go test -race ./logger/...passes;-count=2cleanEnableJSONOutput(true/false)toggles; empty format resets to default; text and JSON formatters both coveredgolangci-lint run ./logger/...adds zero new findings versusmain(9 pre-existinggoconstremain)Fixes dapr/dapr#9853.