MCPcopy
hub / github.com/safing/portmaster / registerBasicOptions

Function registerBasicOptions

base/config/basic_config.go:24–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22}
23
24func registerBasicOptions() error {
25 // Get the default log level from the log package.
26 defaultLogLevel = log.GetLogLevel().Name()
27
28 // Register logging setting.
29 // The log package cannot do that, as it would trigger and import loop.
30 if err := Register(&Option{
31 Name: "Log Level",
32 Key: CfgLogLevel,
33 Description: "Configure the logging level.",
34 OptType: OptTypeString,
35 ExpertiseLevel: ExpertiseLevelDeveloper,
36 ReleaseLevel: ReleaseLevelStable,
37 DefaultValue: defaultLogLevel,
38 Annotations: Annotations{
39 DisplayOrderAnnotation: 513,
40 DisplayHintAnnotation: DisplayHintOneOf,
41 CategoryAnnotation: "Development",
42 },
43 PossibleValues: []PossibleValue{
44 {
45 Name: "Critical",
46 Value: "critical",
47 Description: "The critical level only logs errors that lead to a partial, but imminent failure.",
48 },
49 {
50 Name: "Error",
51 Value: "error",
52 Description: "The error level logs errors that potentially break functionality. Everything logged by the critical level is included here too.",
53 },
54 {
55 Name: "Warning",
56 Value: "warning",
57 Description: "The warning level logs minor errors and worse. Everything logged by the error level is included here too.",
58 },
59 {
60 Name: "Info",
61 Value: "info",
62 Description: "The info level logs the main events that are going on and are interesting to the user. Everything logged by the warning level is included here too.",
63 },
64 {
65 Name: "Debug",
66 Value: "debug",
67 Description: "The debug level logs some additional debugging details. Everything logged by the info level is included here too.",
68 },
69 {
70 Name: "Trace",
71 Value: "trace",
72 Description: "The trace level logs loads of detailed information as well as operation and request traces. Everything logged by the debug level is included here too.",
73 },
74 },
75 }); err != nil {
76 return err
77 }
78 logLevel = GetAsString(CfgLogLevel, defaultLogLevel)
79
80 // Register to hook to update the log level.
81 module.EventConfigChange.AddCallback("update log level", setLogLevel)

Callers 1

prepFunction · 0.85

Calls 5

GetLogLevelFunction · 0.92
GetAsStringFunction · 0.85
RegisterFunction · 0.70
NameMethod · 0.65
AddCallbackMethod · 0.45

Tested by

no test coverage detected