Skip to content

Commit

Permalink
Merge ed08b41 into e5a2d88
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtPattyn committed Jan 4, 2017
2 parents e5a2d88 + ed08b41 commit 1349a00
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .jshintrc
@@ -1,8 +1,7 @@
{
//ENVIRONMENT
"node": true,

"esnext": true,
"esversion": 6,

//ENFORCING OPTIONS
//These options tell jshint to be more strict about the code.
Expand Down
35 changes: 19 additions & 16 deletions lib/karl.js
Expand Up @@ -12,10 +12,10 @@
//disable warnings about unnecessary semicolons
/*jshint -W032 */

var util = require("util");
var os = require("os");
var path = require("path");
var assert = require("assert");
const util = require("util");
const os = require("os");
const path = require("path");
const assert = require("assert");

/**
* Mixes the enumerable properties of the source objects to the target object.
Expand Down Expand Up @@ -72,7 +72,7 @@ const stdout = process.stdout;
* @constant
* @private
*/
const LOG_LEVELS = ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"];
const LOG_LEVELS = ["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"];

/**
* @constant
Expand Down Expand Up @@ -110,7 +110,8 @@ Object.keys(colors._colors).forEach(function(key) {
* @constant
* @private
*/
var logColors = {
const logColors = {
TRACE: colors.green,
DEBUG: colors.defaultTextColor,
INFO: colors.defaultTextColor,
WARN: colors.yellow,
Expand All @@ -119,7 +120,7 @@ var logColors = {
};

/** @private */
var logOptions = defaultLogOptions;
let logOptions = defaultLogOptions;

/**
* Supported formatters:
Expand Down Expand Up @@ -148,7 +149,7 @@ function textFormatter(message) {
}

/** @private */
var formatters = {
const formatters = {
jsonFormatter: jsonFormatter,
textFormatter: textFormatter,

Expand All @@ -162,14 +163,14 @@ var formatters = {
*
* @private
*/
var defaultFormatter = formatters.getFormatter(defaultLogOptions);
const defaultFormatter = formatters.getFormatter(defaultLogOptions);

/**
* The currently active formatter.
*
* @private
*/
var currentFormatter = null;
let currentFormatter = null;

/**
* The karl logger.
Expand All @@ -180,7 +181,7 @@ var currentFormatter = null;
*
* @property {String} version The version of the karl module.
*/
var karl = {
let karl = {
version: require("../package.json").version
};

Expand All @@ -191,7 +192,7 @@ module.exports = karl;
*
* @private
*/
var dummyTrace = {
const dummyTrace = {
getFileName: function() { return null; },
getLineNumber: function() { return null; },
getFunctionName: function() { return null; }
Expand Down Expand Up @@ -382,10 +383,12 @@ LOG_LEVELS.forEach(function(level) {
});

/** @private */
let defaultConsole = {};
let defaultConsole = {
debug: console.log
};

/** @private */
["log", "info", "warn", "error"].forEach(function(level) {
["trace", "log", "info", "warn", "error"].forEach(function(level) {
defaultConsole[level] = console[level];
});

Expand All @@ -398,7 +401,7 @@ function redirectConsole(enable) {
//redirect console.log, .info, .warn and .error logging methods to our logger
console.log = karl.info.bind(karl);

["info", "warn", "error"].forEach(function(level) {
["trace", "debug", "info", "warn", "error"].forEach(function(level) {
console[level] = karl[level].bind(karl);
});
}
Expand All @@ -407,7 +410,7 @@ function redirectConsole(enable) {
/* istanbul ignore else */
if (console.log !== defaultConsole.log) {
//reset to default
["log", "info", "warn", "error"].forEach(function(level) {
["trace", "debug", "log", "info", "warn", "error"].forEach(function(level) {
console[level] = defaultConsole[level];
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "karl",
"version": "1.0.1",
"version": "1.0.2",
"description": "Very fast and simplistic logger that logs to the console.",
"main": "./lib/karl.js",
"scripts": {
Expand Down

0 comments on commit 1349a00

Please sign in to comment.