Added support for 4 logging services
This commit is contained in:
parent
0cc858fb3d
commit
df4da74539
3
.gitignore
vendored
3
.gitignore
vendored
@ -41,6 +41,9 @@ jspm_packages
|
|||||||
# Optional REPL history
|
# Optional REPL history
|
||||||
.node_repl_history
|
.node_repl_history
|
||||||
|
|
||||||
|
# NewRelic APM
|
||||||
|
newrelic.js
|
||||||
|
|
||||||
# Fusebox
|
# Fusebox
|
||||||
.fusebox
|
.fusebox
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Interactive setup
|
- Interactive setup
|
||||||
- Auth: GitHub and Slack authentication providers are now available
|
- Auth: GitHub and Slack authentication providers are now available
|
||||||
- Auth: LDAP authentication provider is now available
|
- Auth: LDAP authentication provider is now available
|
||||||
|
- Logs: Support for the logging services: Bugsnag, Loggly, Papertrail and Rollbar
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Native Compilation Removal: Replaced farmhash with md5
|
- Native Compilation Removal: Replaced farmhash with md5
|
||||||
|
@ -50,6 +50,11 @@ defaults:
|
|||||||
signature:
|
signature:
|
||||||
name: Wiki
|
name: Wiki
|
||||||
email: wiki@example.com
|
email: wiki@example.com
|
||||||
|
externalLogging:
|
||||||
|
bugsnap: false
|
||||||
|
loggly: false
|
||||||
|
papertrail: false
|
||||||
|
rollbar: false
|
||||||
langs:
|
langs:
|
||||||
-
|
-
|
||||||
id: en
|
id: en
|
||||||
|
37550
assets/js/bundle.min.js
vendored
37550
assets/js/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
46278
assets/js/configure.min.js
vendored
Normal file
46278
assets/js/configure.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
client/configure.js
Normal file
4
client/configure.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
require('./scss/configure.scss')
|
||||||
|
require('./js/configure.js')
|
@ -7,10 +7,6 @@ switch (logic) {
|
|||||||
require('./scss/login.scss')
|
require('./scss/login.scss')
|
||||||
require('./js/login.js')
|
require('./js/login.js')
|
||||||
break
|
break
|
||||||
case 'configure':
|
|
||||||
require('./scss/configure.scss')
|
|
||||||
require('./js/configure.js')
|
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
require('./node_modules/highlight.js/styles/tomorrow.css')
|
require('./node_modules/highlight.js/styles/tomorrow.css')
|
||||||
require('./node_modules/simplemde/dist/simplemde.min.css')
|
require('./node_modules/simplemde/dist/simplemde.min.css')
|
||||||
|
@ -131,3 +131,14 @@ git:
|
|||||||
signature:
|
signature:
|
||||||
name: Marty
|
name: Marty
|
||||||
email: marty@example.com
|
email: marty@example.com
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# External Logging
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
externalLogging:
|
||||||
|
bugsnag: false
|
||||||
|
loggly: false
|
||||||
|
papertrail: false
|
||||||
|
rollbar: false
|
||||||
|
|
||||||
|
104
fuse.js
104
fuse.js
@ -19,10 +19,9 @@ const args = require('yargs')
|
|||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
})
|
})
|
||||||
.option('c', {
|
.option('c', {
|
||||||
alias: 'configure',
|
alias: 'dev-configure',
|
||||||
describe: 'Use Configure mode',
|
describe: 'Start in Configure Developer mode',
|
||||||
type: 'boolean',
|
type: 'boolean'
|
||||||
implies: 'd'
|
|
||||||
})
|
})
|
||||||
.help('h')
|
.help('h')
|
||||||
.alias('h', 'help')
|
.alias('h', 'help')
|
||||||
@ -62,34 +61,66 @@ if (args.d) {
|
|||||||
// Server
|
// Server
|
||||||
|
|
||||||
_.delay(() => {
|
_.delay(() => {
|
||||||
if (args.c) {
|
nodemon({
|
||||||
nodemon({
|
script: './server.js',
|
||||||
exec: 'node wiki configure',
|
args: [],
|
||||||
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
|
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
|
||||||
ext: 'js json',
|
ext: 'js json',
|
||||||
watch: [
|
watch: [
|
||||||
'configure.js'
|
'controllers',
|
||||||
],
|
'libs',
|
||||||
env: { 'NODE_ENV': 'development' }
|
'locales',
|
||||||
})
|
'middlewares',
|
||||||
} else {
|
'models',
|
||||||
nodemon({
|
'agent.js',
|
||||||
script: './server.js',
|
'server.js'
|
||||||
args: [],
|
],
|
||||||
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
|
env: { 'NODE_ENV': 'development' }
|
||||||
ext: 'js json',
|
})
|
||||||
watch: [
|
}, 1000)
|
||||||
'controllers',
|
} else if (args.c) {
|
||||||
'libs',
|
// =============================================
|
||||||
'locales',
|
// DEVELOPER MODE
|
||||||
'middlewares',
|
// =============================================
|
||||||
'models',
|
|
||||||
'agent.js',
|
console.info(colors.bgWhite.black(' Starting Fuse in CONFIGURE DEVELOPER mode... '))
|
||||||
'server.js'
|
|
||||||
],
|
const nodemon = require('nodemon')
|
||||||
env: { 'NODE_ENV': 'development' }
|
|
||||||
})
|
// Client
|
||||||
}
|
|
||||||
|
const fuse = fsbx.FuseBox.init({
|
||||||
|
homeDir: './client',
|
||||||
|
outFile: './assets/js/configure.min.js',
|
||||||
|
alias: {
|
||||||
|
vue: 'vue/dist/vue.js'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
[ fsbx.SassPlugin({ includePaths: ['../core'] }), fsbx.CSSPlugin() ],
|
||||||
|
fsbx.BabelPlugin({ comments: false, presets: ['es2015'] }),
|
||||||
|
fsbx.JSONPlugin()
|
||||||
|
],
|
||||||
|
debug: false,
|
||||||
|
log: true
|
||||||
|
})
|
||||||
|
|
||||||
|
fuse.devServer('>configure.js', {
|
||||||
|
port: 4444,
|
||||||
|
httpServer: false
|
||||||
|
})
|
||||||
|
|
||||||
|
// Server
|
||||||
|
|
||||||
|
_.delay(() => {
|
||||||
|
nodemon({
|
||||||
|
exec: 'node wiki configure',
|
||||||
|
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
|
||||||
|
ext: 'js json',
|
||||||
|
watch: [
|
||||||
|
'configure.js'
|
||||||
|
],
|
||||||
|
env: { 'NODE_ENV': 'development' }
|
||||||
|
})
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
// =============================================
|
// =============================================
|
||||||
@ -100,7 +131,9 @@ if (args.d) {
|
|||||||
|
|
||||||
const fuse = fsbx.FuseBox.init({
|
const fuse = fsbx.FuseBox.init({
|
||||||
homeDir: './client',
|
homeDir: './client',
|
||||||
outFile: './assets/js/bundle.min.js',
|
alias: {
|
||||||
|
vue: 'vue/dist/vue.js'
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
[ fsbx.SassPlugin({ outputStyle: 'compressed', includePaths: ['./node_modules/requarks-core'] }), fsbx.CSSPlugin() ],
|
[ fsbx.SassPlugin({ outputStyle: 'compressed', includePaths: ['./node_modules/requarks-core'] }), fsbx.CSSPlugin() ],
|
||||||
fsbx.BabelPlugin({
|
fsbx.BabelPlugin({
|
||||||
@ -118,7 +151,10 @@ if (args.d) {
|
|||||||
log: true
|
log: true
|
||||||
})
|
})
|
||||||
|
|
||||||
fuse.bundle('>index.js').then(() => {
|
fuse.bundle({
|
||||||
|
'./assets/js/bundle.min.js': '>index.js',
|
||||||
|
'./assets/js/configure.min.js': '>configure.js'
|
||||||
|
}).then(() => {
|
||||||
console.info(colors.green.bold('Assets compilation + bundling completed.'))
|
console.info(colors.green.bold('Assets compilation + bundling completed.'))
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error(colors.green.red(' X Bundle compilation failed! ' + err.message))
|
console.error(colors.green.red(' X Bundle compilation failed! ' + err.message))
|
||||||
|
64
libs/logger.js
Normal file
64
libs/logger.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const winston = require('winston')
|
||||||
|
|
||||||
|
module.exports = (isDebug) => {
|
||||||
|
if (typeof PROCNAME === 'undefined') {
|
||||||
|
const PROCNAME = 'SERVER' // eslint-disable-line no-unused-vars
|
||||||
|
}
|
||||||
|
|
||||||
|
// Console + File Logs
|
||||||
|
|
||||||
|
winston.remove(winston.transports.Console)
|
||||||
|
winston.add(winston.transports.Console, {
|
||||||
|
level: (isDebug) ? 'debug' : 'info',
|
||||||
|
prettyPrint: true,
|
||||||
|
colorize: true,
|
||||||
|
silent: false,
|
||||||
|
timestamp: true,
|
||||||
|
filters: [(level, msg, meta) => {
|
||||||
|
return '[' + PROCNAME + '] ' + msg // eslint-disable-line no-undef
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
// External services
|
||||||
|
|
||||||
|
if (appconfig.externalLogging.bugsnag) {
|
||||||
|
const bugsnagTransport = require('./winston-transports/bugsnag')
|
||||||
|
winston.add(bugsnagTransport, {
|
||||||
|
level: 'warn',
|
||||||
|
key: appconfig.externalLogging.bugsnag
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appconfig.externalLogging.loggly) {
|
||||||
|
require('winston-loggly-bulk')
|
||||||
|
winston.add(winston.transports.Loggly, {
|
||||||
|
token: appconfig.externalLogging.loggly.token,
|
||||||
|
subdomain: appconfig.externalLogging.loggly.subdomain,
|
||||||
|
tags: ['wiki-js'],
|
||||||
|
level: 'warn',
|
||||||
|
json: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appconfig.externalLogging.papertrail) {
|
||||||
|
require('winston-papertrail').Papertrail // eslint-disable-line no-unused-expressions
|
||||||
|
winston.add(winston.transports.Papertrail, {
|
||||||
|
host: appconfig.externalLogging.papertrail.host,
|
||||||
|
port: appconfig.externalLogging.papertrail.port,
|
||||||
|
level: 'warn',
|
||||||
|
program: 'wiki.js'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appconfig.externalLogging.rollbar) {
|
||||||
|
const rollbarTransport = require('./winston-transports/rollbar')
|
||||||
|
winston.add(rollbarTransport, {
|
||||||
|
level: 'warn',
|
||||||
|
key: appconfig.externalLogging.rollbar
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return winston
|
||||||
|
}
|
20
libs/winston-transports/bugsnag.js
Normal file
20
libs/winston-transports/bugsnag.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const util = require('util')
|
||||||
|
const winston = require('winston')
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
|
let BugsnagLogger = winston.transports.BugsnagLogger = function (options) {
|
||||||
|
this.name = 'bugsnagLogger'
|
||||||
|
this.level = options.level || 'warn'
|
||||||
|
this.bugsnag = require('bugsnag')
|
||||||
|
this.bugsnag.register(options.key)
|
||||||
|
}
|
||||||
|
util.inherits(BugsnagLogger, winston.Transport)
|
||||||
|
|
||||||
|
BugsnagLogger.prototype.log = function (level, msg, meta, callback) {
|
||||||
|
this.bugsnag.notify(new Error(msg), _.assignIn(meta, { severity: level }))
|
||||||
|
callback(null, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = BugsnagLogger
|
20
libs/winston-transports/rollbar.js
Normal file
20
libs/winston-transports/rollbar.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const util = require('util')
|
||||||
|
const winston = require('winston')
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
|
let RollbarLogger = winston.transports.RollbarLogger = function (options) {
|
||||||
|
this.name = 'rollbarLogger'
|
||||||
|
this.level = options.level || 'warn'
|
||||||
|
this.rollbar = require('rollbar')
|
||||||
|
this.rollbar.init(options.key)
|
||||||
|
}
|
||||||
|
util.inherits(RollbarLogger, winston.Transport)
|
||||||
|
|
||||||
|
RollbarLogger.prototype.log = function (level, msg, meta, callback) {
|
||||||
|
this.rollbar.handleErrorWithPayloadData(new Error(msg), _.assignIn(meta, { level }))
|
||||||
|
callback(null, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = RollbarLogger
|
@ -8,7 +8,7 @@
|
|||||||
"stop": "node wiki stop",
|
"stop": "node wiki stop",
|
||||||
"build": "node fuse",
|
"build": "node fuse",
|
||||||
"dev": "node fuse -d",
|
"dev": "node fuse -d",
|
||||||
"dev-configure": "node fuse -d -c",
|
"dev-configure": "node fuse -c",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"snyk-protect": "snyk protect",
|
"snyk-protect": "snyk protect",
|
||||||
"__prepublish": "npm run snyk-protect",
|
"__prepublish": "npm run snyk-protect",
|
||||||
|
15
server.js
15
server.js
@ -11,22 +11,27 @@ global.ROOTPATH = __dirname
|
|||||||
global.IS_DEBUG = process.env.NODE_ENV === 'development'
|
global.IS_DEBUG = process.env.NODE_ENV === 'development'
|
||||||
global.CORE_PATH = (IS_DEBUG) ? ROOTPATH + '/../core/' : ROOTPATH + '/node_modules/requarks-core/'
|
global.CORE_PATH = (IS_DEBUG) ? ROOTPATH + '/../core/' : ROOTPATH + '/node_modules/requarks-core/'
|
||||||
|
|
||||||
|
if (IS_DEBUG) {
|
||||||
|
try { require('newrelic') } catch (err) {}
|
||||||
|
}
|
||||||
|
|
||||||
process.env.VIPS_WARNING = false
|
process.env.VIPS_WARNING = false
|
||||||
|
|
||||||
|
let appconf = require(CORE_PATH + 'core-libs/config')()
|
||||||
|
global.appconfig = appconf.config
|
||||||
|
global.appdata = appconf.data
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Load Winston
|
// Load Winston
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
global.winston = require(CORE_PATH + 'core-libs/winston')(IS_DEBUG)
|
global.winston = require('./libs/logger')(IS_DEBUG)
|
||||||
winston.info('[SERVER] Wiki.js is initializing...')
|
winston.info('[SERVER] Wiki.js is initializing...')
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Load global modules
|
// Load global modules
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
let appconf = require(CORE_PATH + 'core-libs/config')()
|
|
||||||
global.appconfig = appconf.config
|
|
||||||
global.appdata = appconf.data
|
|
||||||
global.lcdata = require('./libs/local').init()
|
global.lcdata = require('./libs/local').init()
|
||||||
global.db = require(CORE_PATH + 'core-libs/mongodb').init()
|
global.db = require(CORE_PATH + 'core-libs/mongodb').init()
|
||||||
global.entries = require('./libs/entries').init()
|
global.entries = require('./libs/entries').init()
|
||||||
@ -207,6 +212,8 @@ server.on('error', (error) => {
|
|||||||
|
|
||||||
server.on('listening', () => {
|
server.on('listening', () => {
|
||||||
winston.info('[SERVER] HTTP/WS server started successfully! [RUNNING]')
|
winston.info('[SERVER] HTTP/WS server started successfully! [RUNNING]')
|
||||||
|
winston.warn('Something went wrong!')
|
||||||
|
winston.error('An big error occured!')
|
||||||
})
|
})
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
@ -10,7 +10,7 @@ html(data-logic='configure')
|
|||||||
link(rel='icon', type='image/png', sizes=favsize + 'x' + favsize, href='/favicons/favicon-' + favsize + 'x' + favsize + '.png')
|
link(rel='icon', type='image/png', sizes=favsize + 'x' + favsize, href='/favicons/favicon-' + favsize + 'x' + favsize + '.png')
|
||||||
|
|
||||||
// JS / CSS
|
// JS / CSS
|
||||||
script(type='text/javascript', src='/js/bundle.min.js')
|
script(type='text/javascript', src='/js/configure.min.js')
|
||||||
|
|
||||||
block head
|
block head
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user