@@ -38,6 +38,7 @@ import (
3838
3939 "github.com/AliceO2Group/Control/common/utils"
4040 "github.com/sirupsen/logrus"
41+ "github.com/spf13/viper"
4142)
4243
4344const INFOLOGGER_MAX_MESSAGE_SIZE = 1024
4647 hostname string
4748 Pid string
4849 username string
50+
51+ logILInfoLevel = []logrus.Level {
52+ logrus .PanicLevel ,
53+ logrus .FatalLevel ,
54+ logrus .ErrorLevel ,
55+ logrus .WarnLevel ,
56+ logrus .InfoLevel ,
57+ }
58+ logILAllLevel = logrus .AllLevels
59+ currentIlLevel = logILInfoLevel
4960)
5061
62+ func setCurrentILLevelFromViper () {
63+ if viper .GetBool ("logAllIL" ) {
64+ currentIlLevel = logILAllLevel
65+ } else {
66+ currentIlLevel = logILInfoLevel
67+ }
68+ }
69+
5170var lineBreaksRe = regexp .MustCompile (`\r?\n` )
5271
5372func init () {
@@ -140,7 +159,14 @@ func guessSocketPath() string {
140159 }
141160}
142161
143- func NewDirectHook (defaultSystem string , defaultFacility string ) (* DirectHook , error ) {
162+ func NewDirectHook (defaultSystem string , defaultFacility string , levelsToLog []logrus.Level ) (* DirectHook , error ) {
163+
164+ if levelsToLog == nil {
165+ setCurrentILLevelFromViper ()
166+ } else {
167+ currentIlLevel = levelsToLog
168+ }
169+
144170 socketPath := guessSocketPath ()
145171 sender := newSender (socketPath )
146172 if sender == nil {
@@ -154,25 +180,16 @@ func NewDirectHook(defaultSystem string, defaultFacility string) (*DirectHook, e
154180 }, nil
155181}
156182
157- func NewDirectHookWithRole (defaultSystem string , defaultFacility string , defaultRole string ) (* DirectHook , error ) {
158- dh , err := NewDirectHook (defaultSystem , defaultFacility )
183+ func NewDirectHookWithRole (defaultSystem string , defaultFacility string , defaultRole string , levelsToLog []logrus. Level ) (* DirectHook , error ) {
184+ dh , err := NewDirectHook (defaultSystem , defaultFacility , levelsToLog )
159185 if dh != nil {
160186 dh .role = defaultRole
161187 }
162188 return dh , err
163189}
164190
165191func (h * DirectHook ) Levels () []logrus.Level {
166- // Everything except Trace
167- return []logrus.Level {
168- logrus .PanicLevel ,
169- logrus .FatalLevel ,
170- logrus .ErrorLevel ,
171- logrus .WarnLevel ,
172- logrus .InfoLevel ,
173- logrus .DebugLevel ,
174- logrus .TraceLevel ,
175- }
192+ return currentIlLevel
176193}
177194
178195func (h * DirectHook ) Fire (e * logrus.Entry ) error {
0 commit comments