From 9e97d0d59f5343f4cdb9482c4806b1b898e727f6 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Wed, 21 Mar 2018 22:36:13 +0100 Subject: [PATCH] Fix calling logger --- lib/logging/console.js | 87 ------------------------------------------ lib/logging/index.js | 85 ++++++++++++++++++++++++++++++++++++++--- package.json | 17 +++++---- 3 files changed, 90 insertions(+), 99 deletions(-) delete mode 100644 lib/logging/console.js diff --git a/lib/logging/console.js b/lib/logging/console.js deleted file mode 100644 index cda8e0e..0000000 --- a/lib/logging/console.js +++ /dev/null @@ -1,87 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const utils = require('../utils') - -let websocket = null - -const sep = '\n/* ### NEXT TESTCASE ############################## */' -const color = { - red: '\u{1b}[1;31m', - green: '\u{1b}[1;32m', - clear: '\u{1b}[0m' -} -if (utils.platform.name.isWindows) { - color.red = '' - color.green = '' - color.clear = '' -} - -class logger { - static console (msg) { - if (websocket) { - websocket.send(msg) - } - if (typeof window === 'undefined') { - try { - print(msg) // eslint-disable-line no-undef - } catch (e) { - console.log(msg) - } - } else if (window.dump) { - dump(msg) // eslint-disable-line no-undef - } else if (window.console && window.console.log) { - console.log(msg) - } else { - throw new Error('Unable to run console logger.') - } - } - - static dump (msg) { - this.console(msg) - } - - static dumpln (msg) { - this.dump(`${msg}\n`) - } - - static log (msg) { - this.dumpln(`/*L*/ ${utils.script.safely(msg)}`) - } - - static info (msg) { - this.dumpln(`/*L*/ /* ${msg} */`) - } - - static error (msg) { - this.dumpln(color.red + msg + color.clear) - } - - static ok (msg) { // eslint-disable-line no-unused-vars - this.dumpln(color.green + msg + color.green) - } - - static JSError (msg) { - this.error(`/* ERROR: ${msg} */`) - } - - static comment (msg) { - this.dumpln(`/*L*/ // ${msg}`) - } - - static separator () { - this.dumpln(color.green + sep + color.clear) - } - - static traceback () { - this.error('===[ Traceback ] ===') - try { - throw new Error() - } catch (e) { - this.dump(e.stack || e.stacktrace || '') - } - } -} - -module.exports = logger diff --git a/lib/logging/index.js b/lib/logging/index.js index 3468436..cda8e0e 100644 --- a/lib/logging/index.js +++ b/lib/logging/index.js @@ -2,11 +2,86 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -class logging { - static get logger () { - // Or: const {logger} = require('./logging') - return require('./console') +const utils = require('../utils') + +let websocket = null + +const sep = '\n/* ### NEXT TESTCASE ############################## */' +const color = { + red: '\u{1b}[1;31m', + green: '\u{1b}[1;32m', + clear: '\u{1b}[0m' +} +if (utils.platform.name.isWindows) { + color.red = '' + color.green = '' + color.clear = '' +} + +class logger { + static console (msg) { + if (websocket) { + websocket.send(msg) + } + if (typeof window === 'undefined') { + try { + print(msg) // eslint-disable-line no-undef + } catch (e) { + console.log(msg) + } + } else if (window.dump) { + dump(msg) // eslint-disable-line no-undef + } else if (window.console && window.console.log) { + console.log(msg) + } else { + throw new Error('Unable to run console logger.') + } + } + + static dump (msg) { + this.console(msg) + } + + static dumpln (msg) { + this.dump(`${msg}\n`) + } + + static log (msg) { + this.dumpln(`/*L*/ ${utils.script.safely(msg)}`) + } + + static info (msg) { + this.dumpln(`/*L*/ /* ${msg} */`) + } + + static error (msg) { + this.dumpln(color.red + msg + color.clear) + } + + static ok (msg) { // eslint-disable-line no-unused-vars + this.dumpln(color.green + msg + color.green) + } + + static JSError (msg) { + this.error(`/* ERROR: ${msg} */`) + } + + static comment (msg) { + this.dumpln(`/*L*/ // ${msg}`) + } + + static separator () { + this.dumpln(color.green + sep + color.clear) + } + + static traceback () { + this.error('===[ Traceback ] ===') + try { + throw new Error() + } catch (e) { + this.dump(e.stack || e.stacktrace || '') + } } } -module.exports = logging +module.exports = logger diff --git a/package.json b/package.json index 843b93e..2f167c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mozillasecurity/octo", - "version": "1.0.5", + "version": "1.0.8", "description": "", "keywords": [ "fuzzing", @@ -40,21 +40,24 @@ } }, "devDependencies": { - "cross-env": "^5.1.3", + "cross-env": "^5.1.4", "grunt": "*", "grunt-karma": "*", "grunt-karma-coveralls": "*", "grunt-standard": "*", "husky": "^0.14.3", - "jshint": "^2.9.5", "karma": "*", "karma-chrome-launcher": "*", "karma-coverage": "*", - "karma-firefox-launcher": "*", - "karma-qunit": "*", - "qunitjs": "*", - "standard": "*", + "karma-firefox-launcher": "^1.1.0", + "karma-qunit": "^2.0.1", + "qunit": "^2.5.1", + "qunitjs": "^2.4.1", + "standard": "^11.0.1", "webpack": "^4.1.1", "webpack-cli": "^2.0.12" + }, + "dependencies": { + "jsesc": "^2.5.1" } }