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
|
||||
.node_repl_history
|
||||
|
||||
# NewRelic APM
|
||||
newrelic.js
|
||||
|
||||
# Fusebox
|
||||
.fusebox
|
||||
|
||||
|
@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Interactive setup
|
||||
- Auth: GitHub and Slack authentication providers are now available
|
||||
- Auth: LDAP authentication provider is now available
|
||||
- Logs: Support for the logging services: Bugsnag, Loggly, Papertrail and Rollbar
|
||||
|
||||
### Changed
|
||||
- Native Compilation Removal: Replaced farmhash with md5
|
||||
|
@ -50,6 +50,11 @@ defaults:
|
||||
signature:
|
||||
name: Wiki
|
||||
email: wiki@example.com
|
||||
externalLogging:
|
||||
bugsnap: false
|
||||
loggly: false
|
||||
papertrail: false
|
||||
rollbar: false
|
||||
langs:
|
||||
-
|
||||
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('./js/login.js')
|
||||
break
|
||||
case 'configure':
|
||||
require('./scss/configure.scss')
|
||||
require('./js/configure.js')
|
||||
break
|
||||
default:
|
||||
require('./node_modules/highlight.js/styles/tomorrow.css')
|
||||
require('./node_modules/simplemde/dist/simplemde.min.css')
|
||||
|
@ -131,3 +131,14 @@ git:
|
||||
signature:
|
||||
name: Marty
|
||||
email: marty@example.com
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# External Logging
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
externalLogging:
|
||||
bugsnag: false
|
||||
loggly: false
|
||||
papertrail: false
|
||||
rollbar: false
|
||||
|
||||
|
72
fuse.js
72
fuse.js
@ -19,10 +19,9 @@ const args = require('yargs')
|
||||
type: 'boolean'
|
||||
})
|
||||
.option('c', {
|
||||
alias: 'configure',
|
||||
describe: 'Use Configure mode',
|
||||
type: 'boolean',
|
||||
implies: 'd'
|
||||
alias: 'dev-configure',
|
||||
describe: 'Start in Configure Developer mode',
|
||||
type: 'boolean'
|
||||
})
|
||||
.help('h')
|
||||
.alias('h', 'help')
|
||||
@ -62,17 +61,6 @@ if (args.d) {
|
||||
// Server
|
||||
|
||||
_.delay(() => {
|
||||
if (args.c) {
|
||||
nodemon({
|
||||
exec: 'node wiki configure',
|
||||
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
|
||||
ext: 'js json',
|
||||
watch: [
|
||||
'configure.js'
|
||||
],
|
||||
env: { 'NODE_ENV': 'development' }
|
||||
})
|
||||
} else {
|
||||
nodemon({
|
||||
script: './server.js',
|
||||
args: [],
|
||||
@ -89,7 +77,50 @@ if (args.d) {
|
||||
],
|
||||
env: { 'NODE_ENV': 'development' }
|
||||
})
|
||||
}
|
||||
}, 1000)
|
||||
} else if (args.c) {
|
||||
// =============================================
|
||||
// DEVELOPER MODE
|
||||
// =============================================
|
||||
|
||||
console.info(colors.bgWhite.black(' Starting Fuse in CONFIGURE DEVELOPER mode... '))
|
||||
|
||||
const nodemon = require('nodemon')
|
||||
|
||||
// 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)
|
||||
} else {
|
||||
// =============================================
|
||||
@ -100,7 +131,9 @@ if (args.d) {
|
||||
|
||||
const fuse = fsbx.FuseBox.init({
|
||||
homeDir: './client',
|
||||
outFile: './assets/js/bundle.min.js',
|
||||
alias: {
|
||||
vue: 'vue/dist/vue.js'
|
||||
},
|
||||
plugins: [
|
||||
[ fsbx.SassPlugin({ outputStyle: 'compressed', includePaths: ['./node_modules/requarks-core'] }), fsbx.CSSPlugin() ],
|
||||
fsbx.BabelPlugin({
|
||||
@ -118,7 +151,10 @@ if (args.d) {
|
||||
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.'))
|
||||
}).catch(err => {
|
||||
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",
|
||||
"build": "node fuse",
|
||||
"dev": "node fuse -d",
|
||||
"dev-configure": "node fuse -d -c",
|
||||
"dev-configure": "node fuse -c",
|
||||
"test": "jest",
|
||||
"snyk-protect": "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.CORE_PATH = (IS_DEBUG) ? ROOTPATH + '/../core/' : ROOTPATH + '/node_modules/requarks-core/'
|
||||
|
||||
if (IS_DEBUG) {
|
||||
try { require('newrelic') } catch (err) {}
|
||||
}
|
||||
|
||||
process.env.VIPS_WARNING = false
|
||||
|
||||
let appconf = require(CORE_PATH + 'core-libs/config')()
|
||||
global.appconfig = appconf.config
|
||||
global.appdata = appconf.data
|
||||
|
||||
// ----------------------------------------
|
||||
// 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...')
|
||||
|
||||
// ----------------------------------------
|
||||
// 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.db = require(CORE_PATH + 'core-libs/mongodb').init()
|
||||
global.entries = require('./libs/entries').init()
|
||||
@ -207,6 +212,8 @@ server.on('error', (error) => {
|
||||
|
||||
server.on('listening', () => {
|
||||
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')
|
||||
|
||||
// JS / CSS
|
||||
script(type='text/javascript', src='/js/bundle.min.js')
|
||||
script(type='text/javascript', src='/js/configure.min.js')
|
||||
|
||||
block head
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user