Skip to content

Commit 7cc0f7d

Browse files
committed
Update logging
1 parent 5a94b7d commit 7cc0f7d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

bin/start.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const { createMetadata } = require('../lib/metadata')
88
const { HyperdriveClient } = require('hyperdrive-daemon-client')
99

1010
const HYPERDRIVE_DIR = p.join(os.homedir(), '.hyperdrive')
11+
const OUTPUT_FILE = p.join(HYPERDRIVE_DIR, 'output.log')
1112

1213
exports.command = 'start'
1314
exports.desc = 'Start the Hyperdrive daemon.'
@@ -57,9 +58,9 @@ async function start (argv) {
5758
forever.startDaemon(p.join(__dirname, '..', 'index.js'), {
5859
uid: 'hyperdrive',
5960
max: 1,
60-
logFile: './hyperdrive.log',
61-
outFile: './hyperdrive.log',
62-
errFile: './hyperdrive.log',
61+
logFile: OUTPUT_FILE,
62+
outFile: OUTPUT_FILE,
63+
errFile: OUTPUT_FILE,
6364
args: ['--port', argv.port, '--storage', argv.storage, '--log-level', argv['log-level'], '--bootstrap', argv.bootstrap.join(',')]
6465
})
6566
console.log(chalk.green(`Daemon started at ${endpoint}`))

lib/log.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
const os = require('os')
2+
const p = require('path')
3+
14
const pino = require('pino')
25
const argv = require('yargs').argv
36

7+
// TODO: Move to a consts file.
8+
const LOGFILE = p.join(os.homedir(), '.hyperdrive', 'log.json')
9+
410
// Forever will redirect stdout to the correct log file.
511
module.exports = pino({
612
name: 'hyperdrive',
713
level: argv['log-level'] || 'info',
814
enabled: true,
9-
}, pino.destination(2))
15+
}, LOGFILE)

0 commit comments

Comments
 (0)