From 8a246a07b4df284a8910abadaff9c0325827ec09 Mon Sep 17 00:00:00 2001 From: miampf Date: Wed, 24 Jan 2024 13:25:19 +0100 Subject: [PATCH] updated conventions.md to more idiomatic suggestion --- dev-docs/conventions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-docs/conventions.md b/dev-docs/conventions.md index d6b244cbc..bdf16d39c 100644 --- a/dev-docs/conventions.md +++ b/dev-docs/conventions.md @@ -40,12 +40,12 @@ Further we try to adhere to the following guidelines: log.Error("A critical error occurred!") ``` -* Use the `With()` method to add structured context to your log messages. The context tags should be easily searchable to allow for easy log filtering. Try to keep consistent tag naming! +* Use additional arguments to add structured context to your log messages. The context tags should be easily searchable to allow for easy log filtering. Try to keep consistent tag naming! Example: ```Go - log.With(slog.Any("error" someError), slog.String("ip", "192.0.2.1")).Error("Connecting to IP failed") + log.Error("Connecting to IP failed", "error", someError, "ip", "192.0.2.1") ``` * Log messages may use format strings to produce human readable messages. However, the information should also be present as structured context fields if it might be valuable for debugging purposes. So, instead of writing