Skip to content

Tags: go-logr/logr

Tags

v1.4.2

Toggle v1.4.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request #295 from go-logr/dependabot/github_actions/action…

…s/checkout-4.1.6

build(deps): bump actions/checkout from 4.1.5 to 4.1.6

v1.4.1

Toggle v1.4.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
slogr: fix unintended API break in v0.8.0 (#253)

* github: check for API changes with Go 1.21.x

An API break in https://github.com/go-logr/logr/pull/237/files#r1434203442
wasn't noticed because the apidiff tool ran with 1.20.x.

* slogr: fix unintended API break in v0.8.0

logr v0.7.0 had slogr.NewSlogHandler. We must keep that function for API
compatibility. https://github.com/go-logr/logr/pull/237/files#r1434203442
accidentally renamed it.

v1.4.0

Toggle v1.4.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
funcr: Add LogInfoLevel Option to skip logging level in the info log (#…

…240)

* funcr: Add LogInfoLevel Option to skip logging level in the info log

Benchmark before:
```
goos: darwin
goarch: arm64
pkg: github.com/go-logr/logr/benchmark
BenchmarkDiscardLogInfoOneArg-10              	58466427	       21.36 ns/op	     32 B/op	      1 allocs/op
BenchmarkDiscardLogInfoSeveralArgs-10         	24470527	       49.62 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogInfoWithValues-10          	21938677	       47.06 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogV0Info-10                  	24796845	       47.45 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogV9Info-10                  	26069977	       49.02 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogError-10                   	23731986	       47.94 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardWithValues-10                 	50995291	       22.28 ns/op	     64 B/op	      1 allocs/op
BenchmarkDiscardWithName-10                   	1000000000	        0.4716 ns/op	      0 B/op	      0 allocs/op
BenchmarkFuncrLogInfoOneArg-10                	2684097	      433.9 ns/op	   1152 B/op	      7 allocs/op
BenchmarkFuncrJSONLogInfoOneArg-10            	2413437	      480.4 ns/op	   1168 B/op	      8 allocs/op
BenchmarkFuncrLogInfoSeveralArgs-10           	1261210	      953.2 ns/op	   1448 B/op	     17 allocs/op
BenchmarkFuncrJSONLogInfoSeveralArgs-10       	1000000	     1003 ns/op	   1448 B/op	     18 allocs/op
BenchmarkFuncrLogInfoWithValues-10            	1247379	     1027 ns/op	   1480 B/op	     17 allocs/op
BenchmarkFuncrJSONLogInfoWithValues-10        	1000000	     1109 ns/op	   1496 B/op	     18 allocs/op
BenchmarkFuncrLogV0Info-10                    	1000000	     1043 ns/op	   1448 B/op	     17 allocs/op
BenchmarkFuncrJSONLogV0Info-10                	1000000	     1100 ns/op	   1448 B/op	     18 allocs/op
BenchmarkFuncrLogV9Info-10                    	24429925	       48.76 ns/op	    176 B/op	      2 allocs/op
BenchmarkFuncrJSONLogV9Info-10                	24799878	       53.82 ns/op	    176 B/op	      2 allocs/op
BenchmarkFuncrLogError-10                     	1000000	     1010 ns/op	   1480 B/op	     19 allocs/op
BenchmarkFuncrJSONLogError-10                 	1000000	     1124 ns/op	   1496 B/op	     20 allocs/op
BenchmarkFuncrWithValues-10                   	4088592	      296.0 ns/op	    264 B/op	      8 allocs/op
BenchmarkFuncrWithName-10                     	34046577	       32.95 ns/op	     96 B/op	      1 allocs/op
BenchmarkFuncrWithCallDepth-10                	34601535	       32.77 ns/op	     96 B/op	      1 allocs/op
BenchmarkFuncrJSONLogInfoStringerValue-10     	2062101	      562.0 ns/op	   1200 B/op	     10 allocs/op
BenchmarkFuncrJSONLogInfoErrorValue-10        	2278339	      529.9 ns/op	   1200 B/op	     10 allocs/op
BenchmarkFuncrJSONLogInfoMarshalerValue-10    	2108040	      533.6 ns/op	   1200 B/op	     10 allocs/op
```

Benchmark after:
```
goos: darwin
goarch: arm64
pkg: github.com/go-logr/logr/benchmark
BenchmarkDiscardLogInfoOneArg-10              	59617632	       20.01 ns/op	     32 B/op	      1 allocs/op
BenchmarkDiscardLogInfoSeveralArgs-10         	26171325	       47.09 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogInfoWithValues-10          	25975759	       45.76 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogV0Info-10                  	25654935	       46.02 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogV9Info-10                  	25722668	       46.00 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardLogError-10                   	25181846	       45.97 ns/op	    176 B/op	      2 allocs/op
BenchmarkDiscardWithValues-10                 	53340940	       21.92 ns/op	     64 B/op	      1 allocs/op
BenchmarkDiscardWithName-10                   	1000000000	        0.4757 ns/op	      0 B/op	      0 allocs/op
BenchmarkFuncrLogInfoOneArg-10                	2887884	      416.5 ns/op	   1152 B/op	      7 allocs/op
BenchmarkFuncrJSONLogInfoOneArg-10            	2556847	      474.0 ns/op	   1168 B/op	      8 allocs/op
BenchmarkFuncrLogInfoSeveralArgs-10           	1280838	      957.4 ns/op	   1448 B/op	     17 allocs/op
BenchmarkFuncrJSONLogInfoSeveralArgs-10       	1000000	     1003 ns/op	   1448 B/op	     18 allocs/op
BenchmarkFuncrLogInfoWithValues-10            	1241484	      967.6 ns/op	   1480 B/op	     17 allocs/op
BenchmarkFuncrJSONLogInfoWithValues-10        	1000000	     1021 ns/op	   1496 B/op	     18 allocs/op
BenchmarkFuncrLogV0Info-10                    	1202900	      925.3 ns/op	   1448 B/op	     17 allocs/op
BenchmarkFuncrJSONLogV0Info-10                	1000000	     1021 ns/op	   1448 B/op	     18 allocs/op
BenchmarkFuncrLogV9Info-10                    	24424683	       48.45 ns/op	    176 B/op	      2 allocs/op
BenchmarkFuncrJSONLogV9Info-10                	24633237	       48.23 ns/op	    176 B/op	      2 allocs/op
BenchmarkFuncrLogError-10                     	1000000	     1066 ns/op	   1480 B/op	     19 allocs/op
BenchmarkFuncrJSONLogError-10                 	1072557	     1093 ns/op	   1496 B/op	     20 allocs/op
BenchmarkFuncrWithValues-10                   	4094355	      292.9 ns/op	    264 B/op	      8 allocs/op
BenchmarkFuncrWithName-10                     	36661557	       33.96 ns/op	     96 B/op	      1 allocs/op
BenchmarkFuncrWithCallDepth-10                	32008606	       32.65 ns/op	     96 B/op	      1 allocs/op
BenchmarkFuncrJSONLogInfoStringerValue-10     	2329975	      517.9 ns/op	   1200 B/op	     10 allocs/op
BenchmarkFuncrJSONLogInfoErrorValue-10        	2200308	      522.0 ns/op	   1200 B/op	     10 allocs/op
BenchmarkFuncrJSONLogInfoMarshalerValue-10    	2242267	      536.0 ns/op	   1200 B/op	     10 allocs/op
```

The performance is similar. Only a nil pointer check is added in the main path.

Signed-off-by: spacewander <[email protected]>

* apply @thockin's suggestion

Signed-off-by: spacewander <[email protected]>

---------

Signed-off-by: spacewander <[email protected]>

v1.3.0

Toggle v1.3.0's commit message

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
docs: interoperability with slog

This assumes that context helper
functions (#213) for slog will not get
merged. If that is the consensus, then this documentation should be the last
missing piece for slog support in logr.

v1.2.4

Toggle v1.2.4's commit message

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
make Discard logger equal to null logger

The original intention was to no treat the discard log sink in a special way.
But it needs special treatment and lacking that in V() led to a bug:
Discard() became different from Discard().V(1).

Adding special detection of the discard logger also helps with the future
logging of context values, because that extra work can be skipped for the
discard logger.

The distinction between null logger (from
#153) and logr.Discard() was very
minor. Instead of fixing the issue above with checks for both cases, Discard()
now simply returns the null logger.

Performance is a bit better:

name                               old time/op    new time/op    delta
DiscardLogInfoOneArg-36              92.7ns ± 5%    88.2ns ± 3%     ~     (p=0.056 n=5+5)
DiscardLogInfoSeveralArgs-36          239ns ± 0%     231ns ± 1%   -3.40%  (p=0.008 n=5+5)
DiscardLogInfoWithValues-36           240ns ± 1%     236ns ± 3%     ~     (p=0.889 n=5+5)
DiscardLogV0Info-36                   234ns ± 1%     228ns ± 0%   -2.62%  (p=0.008 n=5+5)
DiscardLogV9Info-36                   241ns ± 2%     228ns ± 0%   -5.23%  (p=0.008 n=5+5)
DiscardLogError-36                    264ns ± 1%     230ns ± 0%  -12.78%  (p=0.008 n=5+5)
DiscardWithValues-36                  116ns ± 1%     110ns ± 1%   -5.35%  (p=0.008 n=5+5)
DiscardWithName-36                   2.25ns ± 0%    0.72ns ± 0%  -68.12%  (p=0.008 n=5+5)
FuncrLogInfoOneArg-36                2.13µs ± 2%    2.16µs ± 1%     ~     (p=0.222 n=5+5)
FuncrJSONLogInfoOneArg-36            2.41µs ± 1%    2.42µs ± 1%     ~     (p=0.246 n=5+5)
FuncrLogInfoSeveralArgs-36           4.53µs ± 4%    4.40µs ± 4%     ~     (p=0.151 n=5+5)
FuncrJSONLogInfoSeveralArgs-36       4.71µs ± 8%    4.67µs ± 2%     ~     (p=0.310 n=5+5)
FuncrLogInfoWithValues-36            4.60µs ± 2%    4.61µs ± 4%     ~     (p=0.595 n=5+5)
FuncrJSONLogInfoWithValues-36        4.81µs ± 3%    4.84µs ± 3%     ~     (p=1.000 n=5+5)
FuncrLogV0Info-36                    4.45µs ± 3%    4.55µs ± 3%     ~     (p=0.222 n=5+5)
FuncrJSONLogV0Info-36                4.83µs ± 2%    4.78µs ± 3%     ~     (p=0.548 n=5+5)
FuncrLogV9Info-36                     259ns ± 1%     252ns ± 0%   -2.48%  (p=0.008 n=5+5)
FuncrJSONLogV9Info-36                 258ns ± 1%     252ns ± 1%   -2.52%  (p=0.008 n=5+5)
FuncrLogError-36                     4.97µs ± 1%    4.78µs ± 3%   -3.77%  (p=0.032 n=5+5)
FuncrJSONLogError-36                 5.20µs ± 3%    5.13µs ± 2%     ~     (p=0.548 n=5+5)
FuncrWithValues-36                   1.39µs ± 3%    1.38µs ± 3%     ~     (p=0.690 n=5+5)
FuncrWithName-36                      217ns ± 1%     215ns ± 1%   -0.62%  (p=0.040 n=5+5)
FuncrWithCallDepth-36                 206ns ± 1%     210ns ± 1%   +1.92%  (p=0.008 n=5+5)
FuncrJSONLogInfoStringerValue-36     2.59µs ± 2%    2.59µs ± 2%     ~     (p=1.000 n=5+5)
FuncrJSONLogInfoErrorValue-36        2.61µs ± 2%    2.63µs ± 2%     ~     (p=0.310 n=5+5)
FuncrJSONLogInfoMarshalerValue-36    2.63µs ± 2%    2.63µs ± 1%     ~     (p=0.841 n=5+5)

There's no difference in allocations.

Co-authored-by: Tim Hockin <[email protected]>
See #158 (comment)

v1.2.3

Toggle v1.2.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Merge pull request #128 from thockin/format-test

Format and add tests

v1.2.2

Toggle v1.2.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Merge pull request #124 from thockin/master

funcr: Prevent stack overflow on recursive structs

v1.2.1

Toggle v1.2.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Merge pull request #122 from thockin/master

funcr: fix example verbosity

v1.2.0

Toggle v1.2.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Merge pull request #114 from thockin/master

funcr: Allow customization of the timestamp format

v1.2.0-rc1

Toggle v1.2.0-rc1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Merge pull request #113 from thockin/funcr-qstr

funcr: Escape strings when they are not known-safe.