@@ -1751,14 +1751,14 @@ func IsLocalhost(host string) bool {
1751
1751
return host == "localhost" || host == "127.0.0.1" || host == "::1"
1752
1752
}
1753
1753
1754
- var _ slog.Sink = & filterSink {}
1754
+ var _ slog.Sink = & debugFilterSink {}
1755
1755
1756
- type filterSink struct {
1756
+ type debugFilterSink struct {
1757
1757
next []slog.Sink
1758
1758
re * regexp.Regexp
1759
1759
}
1760
1760
1761
- func (f * filterSink ) compile (res []string ) error {
1761
+ func (f * debugFilterSink ) compile (res []string ) error {
1762
1762
if len (res ) == 0 {
1763
1763
return nil
1764
1764
}
@@ -1779,17 +1779,19 @@ func (f *filterSink) compile(res []string) error {
1779
1779
return nil
1780
1780
}
1781
1781
1782
- func (f * filterSink ) LogEntry (ctx context.Context , ent slog.SinkEntry ) {
1783
- logName := strings .Join (ent .LoggerNames , "." )
1784
- if f .re != nil && ! f .re .MatchString (logName ) {
1785
- return
1782
+ func (f * debugFilterSink ) LogEntry (ctx context.Context , ent slog.SinkEntry ) {
1783
+ if ent .Level == slog .LevelDebug {
1784
+ logName := strings .Join (ent .LoggerNames , "." )
1785
+ if f .re != nil && ! f .re .MatchString (logName ) {
1786
+ return
1787
+ }
1786
1788
}
1787
1789
for _ , sink := range f .next {
1788
1790
sink .LogEntry (ctx , ent )
1789
1791
}
1790
1792
}
1791
1793
1792
- func (f * filterSink ) Sync () {
1794
+ func (f * debugFilterSink ) Sync () {
1793
1795
for _ , sink := range f .next {
1794
1796
sink .Sync ()
1795
1797
}
@@ -1844,7 +1846,7 @@ func BuildLogger(inv *clibase.Invocation, cfg *codersdk.DeploymentValues) (slog.
1844
1846
return slog.Logger {}, nil , xerrors .New ("no loggers provided" )
1845
1847
}
1846
1848
1847
- filter := & filterSink {next : sinks }
1849
+ filter := & debugFilterSink {next : sinks }
1848
1850
1849
1851
err = filter .compile (cfg .Logging .Filter .Value ())
1850
1852
if err != nil {
0 commit comments