Socket
Socket
Sign inDemoInstall

console-stamp

Package Overview
Dependencies
60
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.2.2

54

main.js

@@ -10,3 +10,3 @@ /*jshint node:true, bitwise:false */

var dateFormat = require( "dateformat" );
var defaultDateFormat = require( "dateformat" );
var merge = require( "merge" );

@@ -36,2 +36,4 @@ var chalk = require( "chalk" );

var dateFormat = options.formatter || defaultDateFormat;
options.include = options.include.filter( function filter( m ) {

@@ -42,26 +44,22 @@ return !~options.exclude.indexOf( m );

//SET COLOR THEME START
var noColor = function(str){ return str; }; //Default behaviour (no color)
var getColor = function(origColor)
{
var noColor = function ( str ) {
return str;
}; //Default behaviour (no color)
var getColor = function ( origColor ) {
//If color is a chalk function already, just return it
if(typeof origColor === 'function')
{
if ( typeof origColor === 'function' ) {
return origColor;
}
//If color is an string, check if a function in chalk exists
if(typeof origColor === 'string')
{
return chalk[""+origColor] ? chalk[""+origColor] : noColor;
if ( typeof origColor === 'string' ) {
return chalk["" + origColor] ? chalk["" + origColor] : noColor;
}
//If color is an array, check the contents for color strings
if(Array.isArray(origColor))
{
if(origColor.length > 0)
{
if ( Array.isArray( origColor ) ) {
if ( origColor.length > 0 ) {
var color = chalk;
for (var i = 0; i < origColor.length; i++) {
if(typeof origColor[i] === 'string')
{
color = color[""+origColor[i]];
for ( var i = 0; i < origColor.length; i++ ) {
if ( typeof origColor[i] === 'string' ) {
color = color["" + origColor[i]];
}

@@ -71,3 +69,3 @@ }

}
else{
else {
return noColor;

@@ -77,10 +75,10 @@ }

return noColor;
}
};
var colorTheme = {};
colorTheme.stamp = getColor(options.colors.stamp);
colorTheme.label = getColor(options.colors.label);
colorTheme.metadata = getColor(options.colors.metadata);
colorTheme.stamp = getColor( options.colors.stamp );
colorTheme.label = getColor( options.colors.label );
colorTheme.metadata = getColor( options.colors.metadata );
//SET COLOR THEME END
var original_functions = [];

@@ -98,3 +96,3 @@

var prefix = colorTheme.stamp("[" + dateFormat( pattern ) + "]")+" ";
var prefix = colorTheme.stamp( "[" + dateFormat( pattern ) + "]" ) + " ";
var args = slice.call( arguments );

@@ -104,3 +102,3 @@

if ( options.label ) {
prefix += colorTheme.label("[" + f.toUpperCase() + "]")+" ".substr( f.length );
prefix += colorTheme.label( "[" + f.toUpperCase() + "]" ) + " ".substr( f.length );
}

@@ -119,3 +117,3 @@

if ( metadata ) {
prefix += colorTheme.metadata(metadata) + " "; //Metadata
prefix += colorTheme.metadata( metadata ) + " "; //Metadata
}

@@ -122,0 +120,0 @@

{
"name": "console-stamp",
"main": "main",
"version": "0.2.1",
"version": "0.2.2",
"author": {

@@ -47,4 +47,5 @@ "name": "Ståle Raknes",

"devDependencies": {
"filesize": "^3.1.2"
"filesize": "^3.1.2",
"moment": "^2.13.0"
}
}

@@ -32,2 +32,4 @@ # console-stamp

* **options.formatter** {Function}<br>A custom date formatter that should return a formmatted date string.
* **options.label** {Boolean}<br>If true it will show the label (LOG | INFO | WARN | ERROR)<br>**Default**: true

@@ -118,2 +120,29 @@

### Custom Formatter Example
Custom forrmatter using moment.js
var moment = require('moment');
moment.locale('ja');
require( "console-stamp" )( console, {
formatter:function(){
return moment().format("LLLL");
}
} );
console.log( "This is a console.log message" );
console.info( "This is a console.info message" );
console.warn( "This is a console.warn message" );
console.error( "This is a console.error message" );
console.dir( {bar: "This is a console.dir message"} );
Result:
[2016年5月12日午前11時10分 木曜日] [LOG] This is a console.log message
[2016年5月12日午前11時10分 木曜日] [INFO] This is a console.info message
[2016年5月12日午前11時10分 木曜日] [WARN] This is a console.warn message
[2016年5月12日午前11時10分 木曜日] [ERROR] This is a console.error message
[2016年5月12日午前11時10分 木曜日] [DIR] { bar: 'This is a console.dir message' }
### Adding Metadata ###

@@ -120,0 +149,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc