code.gitea.io/gitea@v1.22.3/modules/log/logger.go (about) 1 // Copyright 2023 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 // Package log provides logging capabilities for Gitea. 5 // Concepts: 6 // 7 // * Logger: a Logger provides logging functions and dispatches log events to all its writers 8 // 9 // * EventWriter: written log Event to a destination (eg: file, console) 10 // - EventWriterBase: the base struct of a writer, it contains common fields and functions for all writers 11 // - WriterType: the type name of a writer, eg: console, file 12 // - WriterName: aka Mode Name in document, the name of a writer instance, it's usually defined by the config file. 13 // It is called "mode name" because old code use MODE as config key, to keep compatibility, keep this concept. 14 // 15 // * WriterMode: the common options for all writers, eg: log level. 16 // - WriterConsoleOption and others: the specified options for a writer, eg: file path, remote address. 17 // 18 // Call graph: 19 // -> log.Info() 20 // -> LoggerImpl.Log() 21 // -> LoggerImpl.SendLogEvent, then the event goes into writer's goroutines 22 // -> EventWriter.Run() handles the events 23 package log 24 25 // BaseLogger provides the basic logging functions 26 type BaseLogger interface { 27 Log(skip int, level Level, format string, v ...any) 28 GetLevel() Level 29 } 30 31 // LevelLogger provides level-related logging functions 32 type LevelLogger interface { 33 LevelEnabled(level Level) bool 34 35 Trace(format string, v ...any) 36 Debug(format string, v ...any) 37 Info(format string, v ...any) 38 Warn(format string, v ...any) 39 Error(format string, v ...any) 40 Critical(format string, v ...any) 41 } 42 43 type Logger interface { 44 BaseLogger 45 LevelLogger 46 } 47 48 type LogStringer interface { //nolint:revive 49 LogString() string 50 }