Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clix-logger

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clix-logger - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

.eslintrc.js

5

changelog.md
# clix-logger - Changelog
## v2.0.0
- **Refactoring**
- remove legacy libraries - [445fdfb]( https://github.com/royriojas/clix-logger/commit/445fdfb ), [Roy Riojas](https://github.com/Roy Riojas), 09/07/2019 13:59:37
## v1.0.2

@@ -4,0 +9,0 @@ - **Refactoring**

72

index.js

@@ -1,16 +0,15 @@

module.exports = function ( options ) {
var console = require( './lib/console' );
var chalk = require( 'chalk' );
var extend = require( 'extend' );
var util = require( 'util' );
var getTime = require( './lib/get-time' );
module.exports = options => {
const console = require('./lib/console');
const chalk = require('chalk');
const util = require('util');
const getTime = require('./lib/get-time');
var inspect = function ( arg ) {
if ( typeof arg !== 'object' && !Array.isArray( arg ) ) {
const inspect = arg => {
if (typeof arg !== 'object' && !Array.isArray(arg)) {
return arg;
}
return util.inspect( arg, { depth: 3 } );
return util.inspect(arg, { depth: 3 });
};
var opts = extend( true, {
const opts = {
appendTime: true,

@@ -22,3 +21,3 @@ coloredOutput: false,

color: 'yellow',
token: ' ✔ ︎'
token: ' ✔ ︎',
},

@@ -28,3 +27,3 @@ subtle: {

color: 'gray',
token: ' ▸ '
token: ' ▸ ',
},

@@ -34,3 +33,3 @@ error: {

color: 'red',
token: ' ✘ '
token: ' ✘ ',
},

@@ -40,3 +39,3 @@ log: {

color: 'white',
token: ' ℹ︎ '
token: ' ℹ︎ ',
},

@@ -46,3 +45,3 @@ warn: {

color: 'magenta',
token: ' ⚠︎ '
token: ' ⚠︎ ',
},

@@ -53,3 +52,3 @@ print: {

color: 'gray',
token: null
token: null,
},

@@ -59,41 +58,38 @@ success: {

color: 'green',
token: ' ✓ ︎'
}
}
}, options );
token: ' ✓ ︎',
},
},
...options,
};
var defineMethod = function defineMethod( entry, key ) {
return function logMethod() {
if ( opts.quiet && entry.muteable ) {
const defineMethod = function defineMethod(entry, key) {
return function logMethod(...args) {
if (opts.quiet && entry.muteable) {
return;
}
var args = [ ].slice.call( arguments );
if ( opts.appendTime && !entry.noAppendTime ) {
args.unshift( '[' + getTime() + ']' );
if (opts.appendTime && !entry.noAppendTime) {
args.unshift(`[${getTime()}]`);
}
if ( entry.token ) {
args.unshift( entry.token );
if (entry.token) {
args.unshift(entry.token);
}
args = args.map( function ( arg ) {
return opts.coloredOutput ? chalk[ entry.color ]( inspect( arg ) ) : inspect( arg );
} );
args = args.map(arg => (opts.coloredOutput ? chalk[entry.color](inspect(arg)) : inspect(arg)));
var logFn = (key !== 'error') ? 'log' : 'error';
const logFn = key !== 'error' ? 'log' : 'error';
console[ logFn ].apply( console, args );
console[logFn](...args);
};
};
var methods = opts.methods;
const methods = opts.methods;
var log = Object.keys( methods ).reduce( function ( seq, key ) {
seq[ key ] = defineMethod( methods[ key ], key );
const log = Object.keys(methods).reduce((seq, key) => {
seq[key] = defineMethod(methods[key], key);
return seq;
}, { } );
}, {});
return log;
};

@@ -1,6 +0,5 @@

var moment = require( 'moment' );
module.exports = function ( format ) {
module.exports = format => {
const moment = require('moment');
format = format || 'HH:mm:ss';
return moment().format( moment().format( format ) );
return moment().format(moment().format(format));
};

@@ -1,1 +0,1 @@

module.exports = require( './index' )( { coloredOutput: true } );
module.exports = require('./index')({ coloredOutput: true });
{
"name": "clix-logger",
"version": "1.0.2",
"version": "2.0.0",
"description": "Another console log wrapper with colored support and icons",
"main": "index.js",
"engines": {
"node": ">=8.11.1"
},
"scripts": {
"beautify": "esbeautifier index.js 'src/**/*.js' 'lib/**/*.js' 'specs/**/*.js'",
"beautify-check": "esbeautifier -k index.js 'src/**/*.js' 'lib/**/*.js' 'specs/**/*.js'",
"eslint": "eslinter index.js 'src/**/*.js' 'lib/**/*.js' 'specs/**/*.js'",
"lint": "eslint --cache --cache-location node_modules/.cache/ -f friendly '*.js' 'lib/*.js' 'specs/*.js'",
"test": "mocha-runner 'specs/**/*.js'",
"cover": "istanbul cover -x 'specs/**/*.js' mocha-runner 'specs/**/*.js' html text-summary",
"watch": "npm run cover && watch-spawn -p 'specs/**/*.js' -p 'index.js' -p 'src/**/*.js' npm run cover",
"lint": "npm run beautify --silent && npm run eslint --silent && npm test --silent",
"check": "npm run beautify-check && npm run eslint && npm test",
"watch": "watch-spawn -p 'specs/**/*.js' -p 'index.js' -p 'src/**/*.js' -i npm run test",
"check": "npm run lint && npm test",
"changelog": "changelogx -f markdown -o ./changelog.md",
"do-changelog": "npm run changelog && git add ./changelog.md && git commit -m 'DOC: Generate changelog' --no-verify",
"install-hooks": "prepush install && changelogx install-hook && precommit install",
"install-hooks": "changelogx install-hook",
"pre-v": "npm run check",

@@ -30,23 +29,24 @@ "post-v": "npm run do-changelog && git push --no-verify && git push --tags --no-verify",

"author": "Roy Riojas (http://royriojas.com)",
"prepush": [
"npm run check"
],
"precommit": [
"npm run check"
],
"devDependencies": {
"changelogx": "2.0.1",
"esbeautifier": "^4.2.7",
"eslinter": "^2.3.1",
"istanbul": "^0.3.17",
"mocha-runner": "^1.0.8",
"precommit": "^1.1.4",
"prepush": "^3.1.3",
"proxyquire": "^1.6.0",
"watch-spawn": "^1.0.4"
"@typescript-eslint/eslint-plugin": "1.10.2",
"@typescript-eslint/parser": "1.10.2",
"babel-eslint": "10.0.1",
"changelogx": "4.0.0",
"eslint": "5.16.0",
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "4.3.0",
"eslint-formatter-friendly": "6.0.0",
"eslint-plugin-import": "2.17.3",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-mocha": "5.3.0",
"eslint-plugin-prettier": "3.1.0",
"eslint-plugin-react": "7.13.0",
"mocha-runner": "3.0.0",
"prettier": "1.18.2",
"proxyquire": "2.1.0",
"watch-spawn": "2.0.0"
},
"dependencies": {
"chalk": "1.1.3",
"extend": "3.0.0",
"moment": "2.22.2"
"chalk": "2.4.2",
"moment": "2.24.0"
},

@@ -53,0 +53,0 @@ "bugs": {

@@ -1,86 +0,141 @@

describe( 'clix-logger', function () {
describe('clix-logger', () => {
it('should log complex objects', () => {
const proxyquire = require('proxyquire');
const lines = [];
it( 'should log complex objects', function () {
var proxyquire = require( 'proxyquire' );
var lines = [ ];
var l = proxyquire( '../', {
'./lib/get-time': function () {
return '02:45:22';
},
const l = proxyquire('../', {
'./lib/get-time': () => '02:45:22',
'./lib/console': {
log: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
log(...args) {
lines.push(args.join(' '));
},
error: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
}
}
} )( { coloredOutput: false } );
error(...args) {
lines.push(args.join(' '));
},
},
})({ coloredOutput: false });
l.ok( 'a', 'simple', 'message', 'of', 'type', 'ok', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.ok(
'a',
'simple',
'message',
'of',
'type',
'ok',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.subtle( 'a', 'simple', 'message', 'of', 'type', 'subtle', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.subtle(
'a',
'simple',
'message',
'of',
'type',
'subtle',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.log( 'a', 'simple', 'message', 'of', 'type', 'log', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.log(
'a',
'simple',
'message',
'of',
'type',
'log',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.error( 'a', 'simple', 'message', 'of', 'type', 'error', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.error(
'a',
'simple',
'message',
'of',
'type',
'error',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.print( 'a', 'simple', 'message', 'of', 'type', 'print', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.print(
'a',
'simple',
'message',
'of',
'type',
'print',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.success( 'a', 'simple', 'message', 'of', 'type', 'success', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.success(
'a',
'simple',
'message',
'of',
'type',
'success',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.warn( 'a', 'simple', 'message', 'of', 'type', 'warn', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.warn(
'a',
'simple',
'message',
'of',
'type',
'warn',
{
coloredOutput: false,
},
[1, 2, 3],
);
// require( 'fs' ).writeFileSync( './specs/fixtures/complex-objects.txt', lines.join( '\n' ) );
var expected = require( 'fs' ).readFileSync( './specs/fixtures/complex-objects.txt', {
encoding: 'utf8'
} );
const expected = require('fs').readFileSync('./specs/fixtures/complex-objects.txt', {
encoding: 'utf8',
});
expect( lines.join( '\n' ) ).to.equal( expected );
expect(lines.join('\n')).to.equal(expected);
});
} );
it('should log some messages without colors', () => {
const proxyquire = require('proxyquire');
const lines = [];
it( 'should log some messages without colors', function () {
var proxyquire = require( 'proxyquire' );
var lines = [ ];
var l = proxyquire( '../', {
const l = proxyquire('../', {
'./lib/console': {
log: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
log(...args) {
lines.push(args.join(' '));
},
error: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
}
}
} )( { coloredOutput: false, appendTime: false } );
error(...args) {
lines.push(args.join(' '));
},
},
})({ coloredOutput: false, appendTime: false });
l.ok( 'a', 'simple', 'message', 'of', 'type', 'ok' );
l.subtle( 'a', 'simple', 'message', 'of', 'type', 'subtle' );
l.log( 'a', 'simple', 'message', 'of', 'type', 'log' );
l.error( 'a', 'simple', 'message', 'of', 'type', 'error' );
l.print( 'a', 'simple', 'message', 'of', 'type', 'print' );
l.success( 'a', 'simple', 'message', 'of', 'type', 'success' );
l.warn( 'a', 'simple', 'message', 'of', 'type', 'warn' );
l.ok('a', 'simple', 'message', 'of', 'type', 'ok');
l.subtle('a', 'simple', 'message', 'of', 'type', 'subtle');
l.log('a', 'simple', 'message', 'of', 'type', 'log');
l.error('a', 'simple', 'message', 'of', 'type', 'error');
l.print('a', 'simple', 'message', 'of', 'type', 'print');
l.success('a', 'simple', 'message', 'of', 'type', 'success');
l.warn('a', 'simple', 'message', 'of', 'type', 'warn');
var expected = [
const expected = [
' ✔ ︎ a simple message of type ok',

@@ -92,35 +147,32 @@ ' ▸ a simple message of type subtle',

' ✓ ︎ a simple message of type success',
' ⚠︎ a simple message of type warn'
' ⚠︎ a simple message of type warn',
];
expect( lines.join( '\n' ) ).to.equal( expected.join( '\n' ) );
expect(lines.join('\n')).to.equal(expected.join('\n'));
});
} );
it('should only log error, ok, print and success', () => {
const proxyquire = require('proxyquire');
const lines = [];
it( 'should only log error, ok, print and success', function () {
var proxyquire = require( 'proxyquire' );
var lines = [ ];
var l = proxyquire( '../', {
const l = proxyquire('../', {
'./lib/console': {
log: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
log(...args) {
lines.push(args.join(' '));
},
error: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
}
}
} )( { coloredOutput: false, quiet: true, appendTime: false } );
error(...args) {
lines.push(args.join(' '));
},
},
})({ coloredOutput: false, quiet: true, appendTime: false });
l.ok( 'a', 'simple', 'message', 'of', 'type', 'ok' );
l.subtle( 'a', 'simple', 'message', 'of', 'type', 'subtle' );
l.log( 'a', 'simple', 'message', 'of', 'type', 'log' );
l.error( 'a', 'simple', 'message', 'of', 'type', 'error' );
l.print( 'a', 'simple', 'message', 'of', 'type', 'print' );
l.success( 'a', 'simple', 'message', 'of', 'type', 'success' );
l.warn( 'a', 'simple', 'message', 'of', 'type', 'warn' );
l.ok('a', 'simple', 'message', 'of', 'type', 'ok');
l.subtle('a', 'simple', 'message', 'of', 'type', 'subtle');
l.log('a', 'simple', 'message', 'of', 'type', 'log');
l.error('a', 'simple', 'message', 'of', 'type', 'error');
l.print('a', 'simple', 'message', 'of', 'type', 'print');
l.success('a', 'simple', 'message', 'of', 'type', 'success');
l.warn('a', 'simple', 'message', 'of', 'type', 'warn');
var expected = [
const expected = [
' ✔ ︎ a simple message of type ok',

@@ -130,42 +182,38 @@ ' ✘ a simple message of type error',

' ✓ ︎ a simple message of type success',
' ⚠︎ a simple message of type warn'
' ⚠︎ a simple message of type warn',
];
expect( lines.join( '\n' ) ).to.equal( expected.join( '\n' ) );
expect(lines.join('\n')).to.equal(expected.join('\n'));
});
} );
it('should log some messages with colors', () => {
const proxyquire = require('proxyquire');
const lines = [];
it( 'should log some messages with colors', function () {
var proxyquire = require( 'proxyquire' );
var lines = [ ];
var l = proxyquire( '../', {
const l = proxyquire('../', {
'./lib/console': {
log: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
log(...args) {
lines.push(args.join(' '));
},
error: function () {
var args = [ ].slice.call( arguments );
lines.push( args.join( ' ' ) );
}
}
} )( { coloredOutput: true, appendTime: false } );
error(...args) {
lines.push(args.join(' '));
},
},
})({ coloredOutput: true, appendTime: false });
l.ok( 'a', 'simple', 'message', 'of', 'type', 'ok' );
l.subtle( 'a', 'simple', 'message', 'of', 'type', 'subtle' );
l.log( 'a', 'simple', 'message', 'of', 'type', 'log' );
l.error( 'a', 'simple', 'message', 'of', 'type', 'error' );
l.print( 'a', 'simple', 'message', 'of', 'type', 'print' );
l.success( 'a', 'simple', 'message', 'of', 'type', 'success' );
l.warn( 'a', 'simple', 'message', 'of', 'type', 'warn' );
l.ok('a', 'simple', 'message', 'of', 'type', 'ok');
l.subtle('a', 'simple', 'message', 'of', 'type', 'subtle');
l.log('a', 'simple', 'message', 'of', 'type', 'log');
l.error('a', 'simple', 'message', 'of', 'type', 'error');
l.print('a', 'simple', 'message', 'of', 'type', 'print');
l.success('a', 'simple', 'message', 'of', 'type', 'success');
l.warn('a', 'simple', 'message', 'of', 'type', 'warn');
// require( 'fs' ).writeFileSync( './specs/fixtures/colored-output.txt', lines.join( '\n' ) );
var expected = require( 'fs' ).readFileSync( './specs/fixtures/colored-output.txt', {
encoding: 'utf8'
} );
const expected = require('fs').readFileSync('./specs/fixtures/colored-output.txt', {
encoding: 'utf8',
});
expect( lines.join( '\n' ) ).to.equal( expected );
} );
} );
expect(lines.join('\n')).to.equal(expected);
});
});

@@ -1,28 +0,91 @@

var l = require( './logger' );
l.ok( 'a', 'simple', 'message', 'of', 'type', 'ok', {
coloredOutput: false
}, [ 1, 2, 3 ] );
const l = require('./logger');
l.ok(
'a',
'simple',
'message',
'of',
'type',
'ok',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.subtle( 'a', 'simple', 'message', 'of', 'type', 'subtle', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.subtle(
'a',
'simple',
'message',
'of',
'type',
'subtle',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.log( 'a', 'simple', 'message', 'of', 'type', 'log', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.log(
'a',
'simple',
'message',
'of',
'type',
'log',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.error( 'a', 'simple', 'message', 'of', 'type', 'error', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.error(
'a',
'simple',
'message',
'of',
'type',
'error',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.print( 'a', 'simple', 'message', 'of', 'type', 'print', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.print(
'a',
'simple',
'message',
'of',
'type',
'print',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.success( 'a', 'simple', 'message', 'of', 'type', 'success', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.success(
'a',
'simple',
'message',
'of',
'type',
'success',
{
coloredOutput: false,
},
[1, 2, 3],
);
l.warn( 'a', 'simple', 'message', 'of', 'type', 'warn', {
coloredOutput: false
}, [ 1, 2, 3 ] );
l.warn(
'a',
'simple',
'message',
'of',
'type',
'warn',
{
coloredOutput: false,
},
[1, 2, 3],
);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc