| 1 | // Copyright (C) MongoDB, Inc. 2023-present. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | // not use this file except in compliance with the License. You may obtain |
| 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | |
| 7 | package loggerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/ |
| 8 | |
| 9 | import "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 10 | |
| 11 | // DiffToInfo is the number of levels in the Go Driver that come before the |
| 12 | // "Info" level. This should ensure that "Info" is the 0th level passed to the |
| 13 | // sink. |
| 14 | const DiffToInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/DiffToInfo. = 1 |
| 15 | |
| 16 | // Level is an enumeration representing the log severity levels supported by |
| 17 | // the driver. The order of the logging levels is important. The driver expects |
| 18 | // that a user will likely use the "logr" package to create a LogSink, which |
| 19 | // defaults InfoLevel as 0. Any additions to the Level enumeration before the |
| 20 | // InfoLevel will need to also update the "diffToInfo" constant. |
| 21 | type Levelscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/Level# int |
| 22 | |
| 23 | const ( |
| 24 | // LevelOff suppresses logging. |
| 25 | LevelOffscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelOff. Levelscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/Level# = iota |
| 26 | |
| 27 | // LevelInfo enables logging of informational messages. These logs are |
| 28 | // high-level information about normal driver behavior. |
| 29 | LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo. |
| 30 | |
| 31 | // LevelDebug enables logging of debug messages. These logs can be |
| 32 | // voluminous and are intended for detailed information that may be |
| 33 | // helpful when debugging an application. |
| 34 | LevelDebugscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelDebug. |
| 35 | ) |
| 36 | |
| 37 | const ( |
| 38 | levelLiteralOffscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralOff. = "off" |
| 39 | levelLiteralEmergencyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralEmergency. = "emergency" |
| 40 | levelLiteralAlertscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralAlert. = "alert" |
| 41 | levelLiteralCriticalscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralCritical. = "critical" |
| 42 | levelLiteralErrorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralError. = "error" |
| 43 | levelLiteralWarningscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralWarning. = "warning" |
| 44 | levelLiteralNoticescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralNotice. = "notice" |
| 45 | levelLiteralInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralInfo. = "info" |
| 46 | levelLiteralDebugscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralDebug. = "debug" |
| 47 | levelLiteralTracescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralTrace. = "trace" |
| 48 | ) |
| 49 | |
| 50 | var LevelLiteralMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelLiteralMap. = map[string]Levelscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/Level#{ |
| 51 | levelLiteralOffscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralOff.: LevelOffscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelOff., |
| 52 | levelLiteralEmergencyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralEmergency.: LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo., |
| 53 | levelLiteralAlertscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralAlert.: LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo., |
| 54 | levelLiteralCriticalscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralCritical.: LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo., |
| 55 | levelLiteralErrorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralError.: LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo., |
| 56 | levelLiteralWarningscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralWarning.: LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo., |
| 57 | levelLiteralNoticescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralNotice.: LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo., |
| 58 | levelLiteralInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralInfo.: LevelInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelInfo., |
| 59 | levelLiteralDebugscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralDebug.: LevelDebugscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelDebug., |
| 60 | levelLiteralTracescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/levelLiteralTrace.: LevelDebugscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelDebug., |
| 61 | } |
| 62 | |
| 63 | // ParseLevel will check if the given string is a valid environment variable |
| 64 | // for a logging severity level. If it is, then it will return the associated |
| 65 | // driver's Level. The default Level is “LevelOff”. |
| 66 | func ParseLevelscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/ParseLevel().(str string) Levelscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/Level# { |
| 67 | for literal, level := range LevelLiteralMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelLiteralMap. { |
| 68 | if stringsscip-go gomod github.com/golang/go/src go1.18 strings/.EqualFoldscip-go gomod github.com/golang/go/src go1.18 strings/EqualFold().(literal, str) { |
| 69 | return level |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | return LevelOffscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/logger`/LevelOff. |
| 74 | } |