@@ -56,11 +56,6 @@ type Config struct {
56
56
func (c * Config ) GetConfigFolder (xdgPath string ) string {
57
57
configPath := xdgPath
58
58
59
- log .WithFields (log.Fields {
60
- "prefix" : "config.Config.GetProfilesFolder" ,
61
- "path" : configPath ,
62
- }).Debug ("Using profiles file" )
63
-
64
59
if configPath == "" {
65
60
home , err := homedir .Dir ()
66
61
if err != nil {
@@ -71,13 +66,32 @@ func (c *Config) GetConfigFolder(xdgPath string) string {
71
66
configPath = filepath .Join (home , ".config" )
72
67
}
73
68
69
+ log .WithFields (log.Fields {
70
+ "prefix" : "config.Config.GetProfilesFolder" ,
71
+ "path" : configPath ,
72
+ }).Debug ("Using profiles folder" )
73
+
74
74
return filepath .Join (configPath , "hookdeck" )
75
75
}
76
76
77
77
// InitConfig reads in profiles file and ENV variables if set.
78
78
func (c * Config ) InitConfig () {
79
79
c .Profile .Config = c
80
80
81
+ // Set log level
82
+ switch c .LogLevel {
83
+ case "debug" :
84
+ log .SetLevel (log .DebugLevel )
85
+ case "info" :
86
+ log .SetLevel (log .InfoLevel )
87
+ case "warn" :
88
+ log .SetLevel (log .WarnLevel )
89
+ case "error" :
90
+ log .SetLevel (log .ErrorLevel )
91
+ default :
92
+ log .Fatalf ("Unrecognized log level value: %s. Expected one of debug, info, warn, error." , c .LogLevel )
93
+ }
94
+
81
95
logFormatter := & prefixed.TextFormatter {
82
96
FullTimestamp : true ,
83
97
TimestampFormat : time .RFC1123 ,
@@ -102,7 +116,7 @@ func (c *Config) InitConfig() {
102
116
log .WithFields (log.Fields {
103
117
"prefix" : "config.Config.InitConfig" ,
104
118
"path" : c .GlobalConfig .ConfigFileUsed (),
105
- }).Debug ("Using profiles file" )
119
+ }).Debug ("Using global profiles file" )
106
120
}
107
121
108
122
// Read local config
@@ -127,7 +141,7 @@ func (c *Config) InitConfig() {
127
141
log .WithFields (log.Fields {
128
142
"prefix" : "config.Config.InitConfig" ,
129
143
"path" : c .LocalConfig .ConfigFileUsed (),
130
- }).Debug ("Using profiles file" )
144
+ }).Debug ("Using local profiles file" )
131
145
}
132
146
133
147
// Construct the config struct
@@ -155,20 +169,6 @@ func (c *Config) InitConfig() {
155
169
}
156
170
157
171
log .SetFormatter (logFormatter )
158
-
159
- // Set log level
160
- switch c .LogLevel {
161
- case "debug" :
162
- log .SetLevel (log .DebugLevel )
163
- case "info" :
164
- log .SetLevel (log .InfoLevel )
165
- case "warn" :
166
- log .SetLevel (log .WarnLevel )
167
- case "error" :
168
- log .SetLevel (log .ErrorLevel )
169
- default :
170
- log .Fatalf ("Unrecognized log level value: %s. Expected one of debug, info, warn, error." , c .LogLevel )
171
- }
172
172
}
173
173
174
174
// EditConfig opens the configuration file in the default editor.
@@ -250,6 +250,12 @@ func (c *Config) WriteGlobalConfig() error {
250
250
if err := makePath (c .GlobalConfig .ConfigFileUsed ()); err != nil {
251
251
return err
252
252
}
253
+
254
+ log .WithFields (log.Fields {
255
+ "prefix" : "config.Config.WriteGlobalConfig" ,
256
+ "path" : c .GlobalConfig .ConfigFileUsed (),
257
+ }).Debug ("Writing global config" )
258
+
253
259
return c .GlobalConfig .WriteConfig ()
254
260
}
255
261
0 commit comments