forked from ipfs-inactive/js-ipfs-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add missing log cmds and modularize log api(ipfs-inactive#544)
- Loading branch information
Showing
8 changed files
with
148 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
module.exports = (arg) => { | ||
return { | ||
tail: require('./tail')(arg), | ||
ls: require('./ls')(arg), | ||
level: require('./level')(arg) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
const moduleConfig = require('../../module-config') | ||
|
||
module.exports = (arg) => { | ||
const send = moduleConfig(arg) | ||
|
||
return promisify((subsystem, level, opts, callback) => { | ||
if (typeof opts === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
if (typeof subsystem !== 'string') { | ||
return callback(new Error('Invalid subsystem type')) | ||
} | ||
|
||
if (typeof level !== 'string') { | ||
return callback(new Error('Invalid level type')) | ||
} | ||
|
||
send({ | ||
path: 'log/level', | ||
args: [subsystem, level], | ||
qs: opts, | ||
files: undefined, | ||
buffer: true | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
const moduleConfig = require('../../module-config') | ||
|
||
module.exports = (arg) => { | ||
const send = moduleConfig(arg) | ||
|
||
return promisify((callback) => { | ||
send({ | ||
path: 'log/ls' | ||
}, (err, result) => { | ||
if (err) { | ||
return callback(err) | ||
} | ||
|
||
callback(null, result.Strings) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
const pump = require('pump') | ||
const ndjson = require('ndjson') | ||
const moduleConfig = require('../../module-config') | ||
|
||
module.exports = (arg) => { | ||
const send = moduleConfig(arg) | ||
|
||
return promisify((callback) => { | ||
return send({ | ||
path: 'log/tail' | ||
}, (err, response) => { | ||
if (err) { | ||
return callback(err) | ||
} | ||
const outputStream = pump(response, ndjson.parse()) | ||
callback(null, outputStream) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters