fix(eventlog) apply settings upon initialization
This commit applies the logging settings to the logging system upon initialization `ipfs init` and `ipfs daemon --init`. License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 23, 2014 at 17:09 UTC
90ed1482092d7a3ce161a63ae8a0166f2b1101da
1 file changed
+11
-5
cmd/ipfs/init.go
+11
-5
@@ -16,7 +16,8 @@ import (
16
chunk "github.com/jbenet/go-ipfs/importer/chunk"
17
peer "github.com/jbenet/go-ipfs/peer"
18
u "github.com/jbenet/go-ipfs/util"
19
- "github.com/jbenet/go-ipfs/util/debugerror"
19
+ debugerror "github.com/jbenet/go-ipfs/util/debugerror"
20
+ repo "github.com/jbenet/go-ipfs/repo"
21
)
22
23
const nBitsForKeypairDefault = 4096
@@ -251,6 +252,8 @@ func identityConfig(nbits int) (config.Identity, error) {
252
return ident, nil
253
}
254
255
+// initLogs initializes the event logger at the specified path. It uses the
256
+// default log path if no path is provided.
257
func initLogs(logpath string) (config.Logs, error) {
258
if len(logpath) == 0 {
259
var err error
@@ -259,15 +262,18 @@ func initLogs(logpath string) (config.Logs, error) {
262
return config.Logs{}, debugerror.Wrap(err)
263
}
264
}
262
-
265
err := initCheckDir(logpath)
266
if err != nil {
267
return config.Logs{}, debugerror.Errorf("logs: %s", err)
268
}
267
-
268
- return config.Logs{
269
+ conf := config.Logs{
270
Filename: path.Join(logpath, "events.log"),
270
- }, nil
271
+ }
272
+ err = repo.ConfigureEventLogger(conf)
273
+ if err != nil {
274
+ return conf, err
275
+ }
276
+ return conf, nil
277
}
278
279
// initCheckDir ensures the directory exists and is writable