| 1 | // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> |
| 2 | // SPDX-License-Identifier: MIT |
| 3 | |
| 4 | package loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/ |
| 5 | |
| 6 | import ( |
| 7 | "sync/atomicscip-go gomod github.com/golang/go/src go1.20 `sync/atomic`/" |
| 8 | ) |
| 9 | |
| 10 | // LogLevel represents the level at which the logger will emit log messages. |
| 11 | type LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel# int32 |
| 12 | |
| 13 | // Set updates the LogLevel to the supplied value. |
| 14 | func (ll *LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#) Setscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#Set().(newLevel LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#) { |
| 15 | atomicscip-go gomod github.com/golang/go/src go1.20 `sync/atomic`/.StoreInt32scip-go gomod github.com/golang/go/src go1.20 `sync/atomic`/StoreInt32().((*int32)(ll), int32(newLevel)) |
| 16 | } |
| 17 | |
| 18 | // Get retrieves the current LogLevel value. |
| 19 | func (ll *LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#) Getscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#Get().() LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel# { |
| 20 | return LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#(atomicscip-go gomod github.com/golang/go/src go1.20 `sync/atomic`/.LoadInt32scip-go gomod github.com/golang/go/src go1.20 `sync/atomic`/LoadInt32().((*int32)(ll))) |
| 21 | } |
| 22 | |
| 23 | func (ll LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#) Stringscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#String().() string { |
| 24 | switch ll { |
| 25 | case LogLevelDisabledscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDisabled.: |
| 26 | return "Disabled" |
| 27 | case LogLevelErrorscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelError.: |
| 28 | return "Error" |
| 29 | case LogLevelWarnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelWarn.: |
| 30 | return "Warn" |
| 31 | case LogLevelInfoscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelInfo.: |
| 32 | return "Info" |
| 33 | case LogLevelDebugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDebug.: |
| 34 | return "Debug" |
| 35 | case LogLevelTracescip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelTrace.: |
| 36 | return "Trace" |
| 37 | default: |
| 38 | return "UNKNOWN" |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | const ( |
| 43 | // LogLevelDisabled completely disables logging of any events. |
| 44 | LogLevelDisabledscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDisabled. LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel# = iota |
| 45 | // LogLevelError is for fatal errors which should be handled by user code, |
| 46 | // but are logged to ensure that they are seen. |
| 47 | LogLevelErrorscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelError. |
| 48 | // LogLevelWarn is for logging abnormal, but non-fatal library operation. |
| 49 | LogLevelWarnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelWarn. |
| 50 | // LogLevelInfo is for logging normal library operation (e.g. state transitions, etc.). |
| 51 | LogLevelInfoscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelInfo. |
| 52 | // LogLevelDebug is for logging low-level library information (e.g. internal operations). |
| 53 | LogLevelDebugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDebug. |
| 54 | // LogLevelTrace is for logging very low-level library information (e.g. network traces). |
| 55 | LogLevelTracescip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelTrace. |
| 56 | ) |
| 57 | |
| 58 | // LeveledLogger is the basic pion Logger interface. |
| 59 | type LeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger# interface { |
| 60 | Tracescip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Trace.(msg string) |
| 61 | Tracefscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Tracef.(format string, args ...any) |
| 62 | Debugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Debug.(msg string) |
| 63 | Debugfscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Debugf.(format string, args ...any) |
| 64 | Infoscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Info.(msg string) |
| 65 | Infofscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Infof.(format string, args ...any) |
| 66 | Warnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Warn.(msg string) |
| 67 | Warnfscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Warnf.(format string, args ...any) |
| 68 | Errorscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Error.(msg string) |
| 69 | Errorfscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger#Errorf.(format string, args ...any) |
| 70 | } |
| 71 | |
| 72 | // LoggerFactory is the basic pion LoggerFactory interface. |
| 73 | type LoggerFactoryscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LoggerFactory# interface { |
| 74 | NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LoggerFactory#NewLogger.(scope string) LeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LeveledLogger# |
| 75 | } |