Skip to content

Commit

Permalink
Updated clrlog to 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBehrendt committed Jun 29, 2016
1 parent e10b1dd commit 3e0f9a4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

![Image](https://raw.githubusercontent.com/BernhardBezdek/Clrlog/master/previews/example_output.png "Example output")

#Changes in version 1.6#
- LOG_CUSTOM_VARIABLES allow tracing by also setting TRACE=true when debugging
- Logging messages contain an ISO date string as default
- Logging message type is always exposed [message], [success], [warning], [error]

#Changes in version 1.4#

##Log level changes##
Expand Down
28 changes: 18 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ var Clrlog = null;
process.env.DEBUG = false;
}

if (typeof sProcessEnv === 'string') {
this.processEnv = sProcessEnv;
} else {
sProcessEnv = 'Clrlog';
this.processEnv = 'Clrlog';
}

// The end string for colored messages
var logMethod = 'log';
var logArchive = {};
Expand Down Expand Up @@ -65,7 +72,7 @@ var Clrlog = null;


// Override log method
if (this.trace) {
if (this.trace || ( process.env[sProcessEnv] !== undefined && process.env.TRACE !== undefined)) {
logMethod = 'trace';
}

Expand All @@ -77,7 +84,7 @@ var Clrlog = null;
// Hanlde writing into a logfile
if (this.logFile !== false && this.logLevel.split(',').indexOf(this.type) !== -1) {

var sWriteFile = this.namespace + new Date().toString() + ' | ' + sType.toUpperCase() + ' ᑀ ';
var sWriteFile = new Date().toString() + ' - ' + this.namespace + ' | ' + sType.toUpperCase() + ' ᑀ ';

try {
if (['boolean', 'number', 'string'].indexOf(typeof (mLogdata)) !== -1) {
Expand Down Expand Up @@ -132,23 +139,24 @@ var Clrlog = null;
this.explicityDebug = false;
}

// logMethod = 'warn';

// In debug mode colorized messages are dumped out
if (this.explicityDebug === true || process.env.DEBUG === true || process.env.DEBUG === 'true') {
if (['boolean', 'number', 'string'].indexOf(typeof (mLogdata)) !== -1) {
console[logMethod](this.types[this.type] + this.namespace + mLogdata + this.endLog);
console[logMethod](this.types[this.type] + new Date().toISOString() + ' - ' + this.namespace + ' [' + this.type + '] ' + mLogdata + this.endLog);
} else {
console[logMethod](this.types[this.type]);
console[logMethod](this.namespace);
console[logMethod](new Date().toISOString() + ' - ' + this.namespace + ' [' + this.type + '] ' );
console[logMethod](mLogdata);
console[logMethod](this.endLog);
}
} else if (this.logLevel.indexOf(sType) !== -1) {

if (['boolean', 'number', 'string'].indexOf(typeof (mLogdata)) !== -1) {
console[logMethod](this.namespace + mLogdata);
console[logMethod](new Date().toISOString() + ' - ' + this.namespace + ' [' + this.type + '] ' + mLogdata);
} else {
console[logMethod](this.namespace);
console[logMethod](new Date().toISOString() + ' - ' + this.namespace + ' [' + this.type + '] ');
console[logMethod](mLogdata);
}
}
Expand Down Expand Up @@ -217,7 +225,7 @@ var Clrlog = null;
* @param message
*/
Clrlog.prototype.error = function (message) {
this.constructor(message, 'error', this.logFile);
this.constructor(message, 'error', this.logFile, this.processEnv, this.trace);
};

/**
Expand All @@ -227,7 +235,7 @@ var Clrlog = null;
* @param message
*/
Clrlog.prototype.warning = function (message) {
this.constructor(message, 'warning', this.logFile);
this.constructor(message, 'warning', this.logFile, this.processEnv, this.trace);
};

/**
Expand All @@ -237,7 +245,7 @@ var Clrlog = null;
* @param message
*/
Clrlog.prototype.success = function (message) {
this.constructor(message, 'success', this.logFile);
this.constructor(message, 'success', this.logFile, this.processEnv, this.trace);
};

/**
Expand All @@ -247,7 +255,7 @@ var Clrlog = null;
* @param message
*/
Clrlog.prototype.message = function (message) {
this.constructor(message, 'message', this.logFile);
this.constructor(message, 'message', this.logFile, this.processEnv, this.trace);
};
})();

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "clrlog",
"description": "Lightweight colorful JavaScript application logger with stack trace and logfile support for node.js",
"version": "1.5.1",
"version": "1.6.0",
"author": {
"name": "Bernhard Bezdek",
"email": "[email protected]"
Expand Down
Binary file modified previews/example_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3e0f9a4

Please sign in to comment.