-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log directly to syslog via unix socket
- Loading branch information
1 parent
c6dff95
commit 3702613
Showing
48 changed files
with
9,200 additions
and
4 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const Ain = require('ain2'); | ||
|
||
const ain = new Ain({ | ||
tag: 'node-red', | ||
facility: 'daemon', | ||
path: '/dev/log' | ||
}); | ||
|
||
const allowEmptyLine = false; | ||
|
||
ain.setMessageComposer(function (message, severity) { | ||
return new Buffer('<' + (this.facility * 8 + severity) + '>' + this.tag + '[' + process.pid + ']: ' + message); | ||
}); | ||
|
||
const levelNames = { | ||
10: 'crit', // fatal | ||
20: 'err', | ||
30: 'warn', | ||
40: 'info', | ||
50: 'debug', | ||
60: 'debug', // trace | ||
98: 'debug', // audit | ||
99: 'info' // metric | ||
}; | ||
|
||
module.exports = { | ||
logging: { | ||
ain: { | ||
handler: () => { | ||
return msg => { | ||
if (msg && typeof msg.msg === 'string') { | ||
const lines = msg.msg.split('\n'); | ||
lines.forEach(line => { | ||
if (line || allowEmptyLine) { | ||
const message = (msg.type ? '[' + msg.type + ':' + (msg.name || msg.id) + '] ' : '') + line; | ||
ain.send(message, levelNames[msg.level]); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,36 @@ | ||
const fs = require('fs'); | ||
|
||
const defaults = require('/usr/local/addons/redmatic/lib/node_modules/node-red/settings.js'); | ||
const settings = require('/usr/local/addons/redmatic/etc/settings.json'); | ||
const logging = require('/usr/local/addons/redmatic/lib/logger.js'); | ||
|
||
// Migration | ||
if (settings.logging.console) { | ||
settings.logging.ain = settings.logging.console; | ||
delete settings.logging.console; | ||
fs.writeFileSync('/usr/local/addons/redmatic/etc/settings.json', JSON.stringify(settings, null, ' ')); | ||
} | ||
|
||
// Credentials encryption key | ||
if (fs.existsSync('/usr/local/addons/redmatic/etc/credentials.key')) { | ||
settings.credentialSecret = fs.readFileSync('/usr/local/addons/redmatic/etc/credentials.key').toString(); | ||
} | ||
|
||
// Logging | ||
delete defaults.logging.console; | ||
Object.assign(logging.logging.ain, settings.logging.ain); | ||
|
||
// https://github.com/hobbyquaker/RedMatic/issues/45 | ||
if (!defaults.editorTheme) { | ||
defaults.editorTheme = {}; | ||
} | ||
if (!defaults.editorTheme.projects) { | ||
defaults.editorTheme.projects = {}; | ||
} | ||
defaults.editorTheme.projects.enabled = false; | ||
|
||
module.exports = Object.assign( | ||
require('/usr/local/addons/redmatic/lib/node_modules/node-red/settings.js'), | ||
require('/usr/local/addons/redmatic/etc/settings.json') | ||
defaults, | ||
settings, | ||
logging | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.