@@ -16,7 +16,7 @@ import (
16
16
"github.com/BurntSushi/xgbutil/keybind"
17
17
"github.com/BurntSushi/xgbutil/mousebind"
18
18
"github.com/BurntSushi/xgbutil/xevent"
19
- "go.uber.org/zap "
19
+ "github.com/sirupsen/logrus "
20
20
)
21
21
22
22
var usage = `NAME
@@ -83,23 +83,26 @@ func main() {
83
83
84
84
if opts .config != nil {
85
85
if validPath , err = isPathToConfigValid (* opts .config ); ! (err == nil && validPath ) {
86
- zap .L ().Fatal ("path to the config is not valid" , zap .String ("path" , * opts .config ), zap .Bool ("valid" , validPath ), zap .Error (err ))
86
+ logger .WithFields (logrus.Fields {
87
+ "path" : * opts .config ,
88
+ "valid" : validPath ,
89
+ }).WithError (err ).Fatal ("path to the config is not valid" )
87
90
}
88
91
configFilePath = * opts .config
89
92
} else {
90
93
configFilePath , _ , err = getDefaultConfigPath ()
91
94
if err != nil {
92
- zap . L ( ).Fatal ("can not get default config path" , zap . Error ( err ) )
95
+ logger . WithError ( err ).Fatal ("can not get config path" )
93
96
}
94
97
95
98
if validPath , err = isPathToConfigValid (configFilePath ); ! (err == nil && validPath ) {
96
99
if os .IsNotExist (err ) {
97
100
err = createDefaultConfig ()
98
101
if err != nil {
99
- zap . L ( ).Fatal ("can not create default config" , zap . String ( "path" , configFilePath ), zap . Error ( err ) )
102
+ logger . WithField ( "path" , configFilePath ).Fatal ("can not create default config" )
100
103
}
101
104
} else {
102
- zap . L (). Fatal ("path to the config is not valid" , zap . String ( "path" , configFilePath ), zap . Bool ( "valid" , validPath ), zap . Error ( err ) )
105
+ logger . WithFields (logrus. Fields { "path" : configFilePath , "valid" : validPath }). WithError ( err ). Fatal ("path to the config is not valid" )
103
106
}
104
107
}
105
108
}
@@ -116,7 +119,7 @@ func main() {
116
119
117
120
shell , err = parse (configFilePath , & data )
118
121
if err != nil {
119
- zap . L (). Fatal ("failed to parse config" , zap . String ( "file" , configFilePath ), zap . Error ( err ) )
122
+ logger . WithField ( "file" , configFilePath ). WithError ( err ). Fatal ("failed to parse config" )
120
123
}
121
124
122
125
if opts .parseTime {
@@ -145,7 +148,7 @@ func main() {
145
148
if opts .kill || opts .reload {
146
149
execName , err := os .Executable ()
147
150
if err != nil {
148
- zap . L ( ).Fatal ("can not get executable" , zap . Error ( err ) )
151
+ logger . WithError ( err ).Fatal ("can not get executable" )
149
152
}
150
153
151
154
if opts .kill {
@@ -177,8 +180,7 @@ func main() {
177
180
os .Exit (0 )
178
181
}
179
182
180
- zap .L ().Debug ("starting dxhd" , zap .String ("version" , version ))
181
- zap .L ().Debug ("custom path might be provided" , zap .String ("path" , configFilePath ))
183
+ logger .WithFields (logrus.Fields {"version" : version , "path" : configFilePath }).Debug ("starting dxhd" )
182
184
183
185
// catch these signals
184
186
signals := make (chan os.Signal , 1 )
@@ -193,13 +195,13 @@ toplevel:
193
195
if len (data ) == 0 {
194
196
shell , err = parse (configFilePath , & data )
195
197
if err != nil {
196
- zap . L (). Fatal ("failed to parse config" , zap . String ( "file" , configFilePath ), zap . Error ( err ) )
198
+ logger . WithField ( "file" , configFilePath ). WithError ( err ). Fatal ("failed to parse config" )
197
199
}
198
200
}
199
201
200
202
X , err := xgbutil .NewConn ()
201
203
if err != nil {
202
- zap . L ( ).Fatal ("can not open connection to Xorg" , zap . Error ( err ) )
204
+ logger . WithError ( err ).Fatal ("can not open connection to Xorg" )
203
205
}
204
206
205
207
keybind .Initialize (X )
@@ -208,7 +210,7 @@ toplevel:
208
210
for _ , d := range data {
209
211
err = listenKeybinding (X , errs , d .evtType , shell , d .binding .String (), d .action .String ())
210
212
if err != nil {
211
- zap . L (). Info ( "can not register a keybinding" , zap . String ( "keybinding" , d .binding .String ()), zap . Error (err ))
213
+ logger . WithField ( " keybinding" , d .binding .String ()). WithError (err ). Warn ( "can not register a keybinding" )
212
214
}
213
215
}
214
216
@@ -220,18 +222,18 @@ toplevel:
220
222
select {
221
223
case err = <- errs :
222
224
if err != nil {
223
- zap . L (). Info ("a command resulted into an error" , zap . Error ( err ) )
225
+ logger . WithError ( err ). Warn ("a command resulted into an error" )
224
226
}
225
227
continue
226
228
case sig := <- signals :
227
229
keybind .Detach (X , X .RootWin ())
228
230
mousebind .Detach (X , X .RootWin ())
229
231
xevent .Quit (X )
230
232
if sig == syscall .SIGUSR1 || sig == syscall .SIGUSR2 {
231
- zap . L () .Debug ("user defined signal received, reloading" )
233
+ logger .Debug ("user defined signal received, reloading" )
232
234
continue toplevel
233
235
}
234
- zap . L () .Info ("signal received, shutting down" , zap . String ( "signal" , sig . String ()) )
236
+ logger . WithField ( "signal" , sig . String ()) .Info ("signal received, shutting down" )
235
237
if env , err := strconv .ParseBool (os .Getenv ("STACKTRACE" )); env && err == nil {
236
238
buf := make ([]byte , 1 << 20 )
237
239
stackLen := runtime .Stack (buf , true )
0 commit comments