summaryrefslogtreecommitdiffstats
path: root/modules/log/logger.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-12-12 23:57:56 +0100
commite68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch)
tree97775d6c13b0f416af55314eb6a89ef792474615 /modules/log/logger.go
parentInitial commit. (diff)
downloadforgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz
forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'modules/log/logger.go')
-rw-r--r--modules/log/logger.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/log/logger.go b/modules/log/logger.go
new file mode 100644
index 0000000..a833b6e
--- /dev/null
+++ b/modules/log/logger.go
@@ -0,0 +1,50 @@
+// Copyright 2023 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+// Package log provides logging capabilities for Gitea.
+// Concepts:
+//
+// * Logger: a Logger provides logging functions and dispatches log events to all its writers
+//
+// * EventWriter: written log Event to a destination (eg: file, console)
+// - EventWriterBase: the base struct of a writer, it contains common fields and functions for all writers
+// - WriterType: the type name of a writer, eg: console, file
+// - WriterName: aka Mode Name in document, the name of a writer instance, it's usually defined by the config file.
+// It is called "mode name" because old code use MODE as config key, to keep compatibility, keep this concept.
+//
+// * WriterMode: the common options for all writers, eg: log level.
+// - WriterConsoleOption and others: the specified options for a writer, eg: file path, remote address.
+//
+// Call graph:
+// -> log.Info()
+// -> LoggerImpl.Log()
+// -> LoggerImpl.SendLogEvent, then the event goes into writer's goroutines
+// -> EventWriter.Run() handles the events
+package log
+
+// BaseLogger provides the basic logging functions
+type BaseLogger interface {
+ Log(skip int, level Level, format string, v ...any)
+ GetLevel() Level
+}
+
+// LevelLogger provides level-related logging functions
+type LevelLogger interface {
+ LevelEnabled(level Level) bool
+
+ Trace(format string, v ...any)
+ Debug(format string, v ...any)
+ Info(format string, v ...any)
+ Warn(format string, v ...any)
+ Error(format string, v ...any)
+ Critical(format string, v ...any)
+}
+
+type Logger interface {
+ BaseLogger
+ LevelLogger
+}
+
+type LogStringer interface { //nolint:revive
+ LogString() string
+}