From 0f2ae4a68fc427d488e802e6f79dbf7c032c3749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 9 Jul 2024 11:09:00 +0000 Subject: [PATCH] Fix logging errors and multiple logs --- main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 65a84fc..78b11bd 100644 --- a/main.go +++ b/main.go @@ -32,11 +32,21 @@ func (l Log) String() string { } func (c *Context) Log(message interface{}) { - c.Logger.Write(message, LOGGER_TYPE_LOG, false) + switch v := message.(type) { + default: + c.Logger.Write(fmt.Sprintf("%#v", v)+"\n", LOGGER_TYPE_LOG, false) + case string: + c.Logger.Write(v+"\n", LOGGER_TYPE_LOG, false) + } } func (c *Context) Error(message interface{}) { - c.Logger.Write(message, LOGGER_TYPE_ERROR, false) + switch v := message.(type) { + default: + c.Logger.Write(fmt.Sprintf("%#v", v)+"\n", LOGGER_TYPE_ERROR, false) + case string: + c.Logger.Write(v+"\n", LOGGER_TYPE_ERROR, false) + } } type Request struct {