Commit Graph

60 Commits

Author SHA1 Message Date
Dave Henderson
6262c56132
chore(perf): Pre-allocate where possible (enable prealloc linter) (#88952)
* chore(perf): Pre-allocate where possible (enable prealloc linter)

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* fix TestAlertManagers_buildRedactedAMs

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* prealloc a slice that appeared after rebase

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
2024-06-14 14:16:36 -04:00
Dave Henderson
e21d357d67
chore: Updating linter, fixing some new warnings (#88863) 2024-06-06 13:01:27 -04:00
Serge Zaitsev
6ddb8aeae3
Chore: Moving to slog (folders) (#87000)
* moving folders to slog

* trying to fix the tests

* fix per-logger filters in slog

* allow using slog.Default()

* bring cfg back to keep the pr small

* fix tests

* back to the roots
2024-05-02 09:14:12 +02:00
Todd Treece
72472e5eb7
K8s: Add slog wrapper (#84680) 2024-04-09 18:39:25 +03:00
Charandas
2d1cd82a98
K8s: standalone: use Grafana's logger to stream all logs (#84530)
---
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2024-03-18 19:25:30 +02:00
Sven Grossmann
7e01dde762
Logging: Add WithContextualAttributes to pass log params based on the given context (#74428)
* suggestion to use `RegisterContextualLogProvider`

* add `pluginId`

* change to `WithContextualAttributes`

* move approach to instrumentation.go

* improve `WithContextualAttributes`

* unexport consts

* typo

* remove comment

* add `nil` check
2023-09-07 13:13:34 +02:00
Ryan McKinley
025b2f3011
Chore: use any rather than interface{} (#74066) 2023-08-30 18:46:47 +03:00
Serge Zaitsev
f531074d89
Chore: Fix goimports grouping in pkg/infra (#62421)
* fix goimports

* fix goimports order
2023-01-30 08:32:25 +00:00
Emil Tullstedt
88323a30b7
Logging: Fix running tests multiple times (#60559)
- Create new ctxLogProviders for each scenario to support
go test -count=n for n>1. Currently, it just kept adding providers for
every new run, which would make it add way more key-value pairs to
the provider than necessary.

- Adding a helper method to the scenario to make it easier to set up tests
for logging and easier to read the tests. I also flattened the test file, to
reduce the complexity of each test function.
2022-12-27 16:42:03 +01:00
Kyle Brandt
55d2d872ec
Chore: Missed deprecations due to overly broad lint exclusion (#59732) 2022-12-14 12:32:45 +01:00
Carl Bergquist
a5ace56be8
Plugins: Add username to datasource plugin logging (#59893)
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2022-12-07 13:15:42 +01:00
Marcus Efraimsson
862a6a2fa6
Logging: Introduce API for contextual logging (#55198)
Introduces a FromContext method on the log.Logger interface that 
allows contextual key/value pairs to be attached, e.g. per request, 
so that any logger using this API will automatically get the per request 
context attached. The proposal makes the traceID available for 
contextual logger , if available, and would allow logs originating from 
a certain HTTP request to be correlated with traceID.
In addition, when tracing not enabled, skip adding
traceID=00000000000000000000000000000000
to logs.
2022-09-20 18:32:06 +02:00
Emil Tullstedt
b287047052
Chore: Upgrade Go to 1.19.1 (#54902)
* WIP

* Set public_suffix to a pre Ruby 2.6 version

* we don't need to install python

* Stretch->Buster

* Bump versions in lib.star

* Manually update linter

Sort of messy, but the .mod-file need to contain all dependencies that
use 1.16+ features, otherwise they're assumed to be compiled with
-lang=go1.16 and cannot access generics et al.

Bingo doesn't seem to understand that, but it's possible to manually
update things to get Bingo happy.

* undo reformatting

* Various lint improvements

* More from the linter

* goimports -w ./pkg/

* Disable gocritic

* Add/modify linter exceptions

* lint + flatten nested list

Go 1.19 doesn't support nested lists, and there wasn't an obvious workaround.
https://go.dev/doc/comment#lists
2022-09-12 12:03:49 +02:00
Carl Bergquist
78978048c3
Instrumentation: log the total number of db queries per request (#54647)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
2022-09-05 07:39:22 +02:00
Jo
062d255124
Handle ioutil deprecations (#53526)
* replace ioutil.ReadFile -> os.ReadFile

* replace ioutil.ReadAll -> io.ReadAll

* replace ioutil.TempFile -> os.CreateTemp

* replace ioutil.NopCloser -> io.NopCloser

* replace ioutil.WriteFile -> os.WriteFile

* replace ioutil.TempDir -> os.MkdirTemp

* replace ioutil.Discard -> io.Discard
2022-08-10 15:37:51 +02:00
ying-jeanne
56f3f3fe69
Chore: Remove the old log format (#51526)
* remove the old log format

* fix CI

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-07-08 09:56:30 -05:00
Yuriy Tseretyan
739d3469bc
Chore: Update ConcreteLogger to implement gokit Logger interface (#51599) 2022-06-29 18:16:10 -04:00
Sofia Papagiannaki
84e2e1ec8e
Log: Fix text logging for unsupported types (#51306)
* Fix text log for unsupported types

* Apply suggestions from code review

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-06-23 13:24:26 +02:00
Kat Yang
31630edf0c
Chore: Remove Wrapf (#50128)
* Chore: Remove Wrapf

* Remove all Wrapf refs

* Remove last Wrapf ref

* Fix lint errors

* Remove Wrap and Wrapf definitions

* Remove unnecessary colon
2022-06-06 22:30:31 +02:00
ying-jeanne
4e3f53f106
Chore: Make logger mutable for regression test (#49146)
* Log: make logger mutable

* remove flag from public configuration
2022-05-18 17:04:52 +02:00
Emil Tullstedt
51ff2b8c58
Logging: Unify logging fakes (#48822) 2022-05-06 17:44:22 +02:00
ying-jeanne
f62c261900
fix terminal format (#47718) 2022-04-13 17:37:56 +02:00
ying-jeanne
06d2d44031
put the default logger format and feature toggle to fallback to old logger (#47584) 2022-04-13 11:02:19 +02:00
ying-jeanne
03ba91e8a4
add feature toggle with new format (#47336)
* add feature toggle with new format

* fix some comments ❤️

* Update pkg/infra/log/term/terminal_logger.go

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-04-11 18:50:29 +02:00
ying-jeanne
c525db9cd8
fallback to the v8 logging behavior (#47353) 2022-04-05 20:15:41 +02:00
Marcus Efraimsson
659cf17e10
Logging: Fix syslog messages should be sent with correct severity (#47209) 2022-04-04 12:51:14 +02:00
Marcus Efraimsson
b4346a5613
Logging: Fixes filtering logs based on gokitlog levels (#47195) 2022-04-04 12:36:17 +02:00
Marcus Efraimsson
16db1ad46d
API: Fixes request logging middleware to include userId, orgId, uname (#47183)
Fixes #47006
2022-04-01 13:24:39 +02:00
Emil Tullstedt
7bc821baf2
Logger: Use specified format for file logger (#46970)
Fixes #45941
2022-03-26 11:40:08 +01:00
gotjosh
b1e6f7126a
Logging: Helper to create NopLogger (#46376) 2022-03-09 17:03:58 +00:00
Marcus Efraimsson
ca311bf94f
Logging: Fix server hangs when using log.WithSuffix (#45213)
Fixes a problem where server hangs if setting 
GF_DATABASE_LOG_QUERIES=true.

Ref #44925
2022-02-10 12:51:51 +01:00
Marcus Efraimsson
2082eeb72f
Logging: Fix so that filters can contain commented lines (#45159)
Fixes log filters that contains comments should not be enabled
2022-02-10 09:52:37 +01:00
Marcus Efraimsson
05ea825c76
Chore: Logging improvements (#44925)
Fixing a couple bugs, adds some tests and hopefully decrease 
lock contention when logging.
Switching from using sync.RWMutex to go-kit SwapLogger.
Fixes bug when creating a new logger from an existing one that 
screwed up the keyvals and/or lost the logger name. 

Ref #44681
2022-02-07 16:00:08 +01:00
bolshoytoster
7f2d3055d8
Logging: Fix don't return an error trying to initialize the file logger (#42952)
Fixes #42897

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-02-03 18:17:25 +01:00
Marcus Efraimsson
bc7e55d99b
Chore: Fix log filters (#44681) 2022-02-03 23:20:02 +08:00
Marcus Efraimsson
a23900c4ba
CodeQL: Ignore go/log-injection for terminal logger (#44481) 2022-01-27 19:01:59 +01:00
Ryan McKinley
3c334cd8ba
Logger: avoid panic when time is a string (not fmt.Stringer) (#44497) 2022-01-26 13:17:42 -08:00
Marcus Efraimsson
50fabe8a87
Chore: Implements log15 terminal logger (#44447)
Nicer development/terminal output based on log15 terminal logger.
2022-01-26 12:19:43 +01:00
Yuriy Tseretyan
8114f6b065
Use stack trace context in XORM trace logger (#43780)
* add caller and stack Valuer functions
* Add WithPrefix and WithSuffix similar to what go-kit offers
* replace New with just `with`. Remove filter wrapper because the first argument of the context argument is not logger but additional context.
* update Xorm logger to use custom depth to display the datastore code instead of xorm
2022-01-13 13:30:28 -05:00
ying-jeanne
a8eef45a44
Logger migration from log15 to gokit/log (#41636)
* migrate log15 to gokit/log

* fix console log

* update some unittest

* fix all unittest

* fix the build

* Update pkg/infra/log/log.go

Co-authored-by: Yuriy Tseretyan <tceretian@gmail.com>

* general type vector

* correct the level key

Co-authored-by: Yuriy Tseretyan <tceretian@gmail.com>
2022-01-06 22:28:05 +08:00
ying-jeanne
54de1078c8
remove the global log error/warn etc functions (#41404)
* remove the global log error/warn etc functions and use request context logger whenever possible
2021-11-08 17:56:56 +01:00
ying-jeanne
cedbddafe3
removing the log function after enterprise repo update (#41197) 2021-11-02 22:39:55 +08:00
ying-jeanne
681218275e
remove crit and trace (#40320) 2021-10-26 17:36:24 +02:00
Serge Zaitsev
643c7fa0cb
Chore: update all +build statements (#38782) 2021-09-01 17:38:56 +03:00
Arve Knudsen
7394c98d38
MuxWriter: Handle error for already closed file (#31119)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-02-11 10:34:51 +01:00
Arve Knudsen
c2cad26ca9
Chore: Disable default golangci-lint filter (#29751)
* Disable default golangci-lint filter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix linter warnings

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-15 09:32:06 +01:00
Arve Knudsen
f2b7fbc32a
Chore: Check errors from Close calls (#29562)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-03 10:11:14 +01:00
Arve Knudsen
3c229c6bee
Log: Use os.Open to open file for reading (#29483)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-01 09:28:18 +01:00
Arve Knudsen
294770f411
Chore: Handle wrapped errors (#29223)
* Chore: Handle wrapped errors

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2020-11-19 13:34:28 +01:00
Arve Knudsen
52c154a221
Backend: Rename variables for style conformance (#29097)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-17 17:09:14 +01:00