Last active
June 3, 2017 16:03
-
-
Save pooza/695340ba8d2f3e39f1a35bcd0c67e497 to your computer and use it in GitHub Desktop.
npmlogと多分互換。MastodonのストリーミングAPIが吐き出すログを、syslogに流すやつ。
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
// 使い方 | |
// | |
// このソースを streaming/node_modules/bslogger.js という名前で保存。 | |
// shell-escapeが必要なので、streamingディレクトリに居る時に npm install shell-escape とか実行。 | |
// | |
// そうしたら、index.jsの以下の行を、 | |
// import log from 'npmlog'; | |
// | |
// 以下の2行に置き換え。log.nameはお好みに合わせて。 | |
// import log from 'bslogger'; | |
// log.name = 'mastodon_streaming'; | |
this.name = 'bslogger'; | |
this.error = function (arg1, arg2) { | |
this.log(arg1, arg2); | |
} | |
this.info = function (arg1, arg2) { | |
this.log(arg1, arg2); | |
} | |
this.verbose = function (arg1, arg2) { | |
this.log(arg1, arg2); | |
} | |
this.silly = function (arg1, arg2) { | |
this.log(arg1, arg2); | |
} | |
this.log = function (arg1, arg2) { | |
var exec = require('child_process').exec; | |
var shellescape = require('shell-escape'); | |
var command = [ | |
'logger', | |
'-t', shellescape([this.name]), | |
shellescape([arg1, arg2]), | |
].join(' '); | |
//console.log(command); | |
exec(command); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment