Skip to content

Commit

Permalink
esm
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioespinoza committed Mar 18, 2019
1 parent 30b65db commit 1a0990d
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 150 deletions.
150 changes: 2 additions & 148 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,148 +1,2 @@
const _ = require('lodash')
const util = require('util')
require('colors')

const log = {
blue: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.blue)
},
red: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.red)
},
green: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.green)
},
pink: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.red.dim)
},
yellow: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.yellow.bold)
},
violet: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.magenta.dim)
},
magenta: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.magenta.bold)
},
cyan: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.cyan)
}
}
const _log = {
deep: data => {
const options = {
showHidden: false,
depth: null,
colors: true
}
const inspect = util.inspect(data, options)
console.log(inspect)
},
info: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(` Info: ${msg} `.bgBlue)
},
error: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(` ERROR: ${msg} `.yellow)
},
alert: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(` Alert: ${msg} `.bgYellow)
},
warn: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(` Warn: ${msg} `.bgMagenta)
},
blue: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.bgBlue)
},
red: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.bgRed)
},
green: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.bgGreen)
},
pink: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.bgRed)
},
yellow: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.bgYellow)
},
violet: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.bgMagenta)
},
cyan: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg)
}
console.log(`${msg} `.bgCyan)
},
assert: (item, item_name) => {
if (item) {
let msg = ` SUCCESS: ${item_name} = ${item} `
console.log(`ASSERT`, msg.bgCyan)
} else {
let msg = ` FAIL: ${item_name} = ${item} `
console.log(`ASSERT`, msg.bgRed)
}
},
timer: (method, method_name) => {
console.time(`Timer ${method_name}()`)
method()
console.timeEnd(`Timer ${method_name}()`)
},
log: log
}
exports.log = log
module.exports = _log
require = require('esm')(module /*, options*/)
module.exports = require('./src/index.js')
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "@flavioespinoza/log_log",
"version": "1.0.64",
"description": "Color logs",
"esm": true,
"main": "index.js",
"types": "src/index.d.ts",
"scripts": {
"build": "tsc",
"test": "echo \"Error: no test specified\" && exit 1",
"example": "node -r esm example.js",
"roll": "rollup src/main.js -o bundle.js -f cjs"
"roll": "rollup src/main.js -o src/bundle.js -f cjs"
},
"repository": "git+https://github.com/flavioespinoza/log_log.git",
"keywords": [
Expand Down
161 changes: 161 additions & 0 deletions src/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var _ = _interopDefault(require('lodash'));
var util = _interopDefault(require('util'));
require('colors');

const log = {
babyBlue: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.blue.dim);
},
blue: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.blue);
},
red: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.red);
},
green: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.green);
},
pink: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.red.dim);
},
yellow: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.yellow.bold);
},
violet: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.magenta.dim);
},
magenta: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.magenta.bold);
},
cyan: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.cyan);
}
};
const _log = {
deep: (data) => {
const options = {
showHidden: false,
depth: null,
colors: true
};
const inspect = util.inspect(data, options);
console.log(inspect);
},
info: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(` Info: ${msg} `.bgBlue);
},
error: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(` ERROR: ${msg} `.yellow);
},
alert: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(` Alert: ${msg} `.bgYellow);
},
warn: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(` Warn: ${msg} `.bgMagenta);
},
blue: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.bgBlue);
},
red: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.bgRed);
},
green: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.bgGreen);
},
pink: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.bgRed);
},
yellow: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.bgYellow);
},
violet: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.bgMagenta);
},
cyan: (msg) => {
if (typeof msg === 'object') {
msg = _.toString(msg);
}
console.log(`${msg} `.bgCyan);
},
assert: (item, item_name) => {
if (item) {
let msg = ` SUCCESS: ${item_name} = ${item} `;
console.log(`ASSERT`, msg.bgCyan);
}
else {
let msg = ` FAIL: ${item_name} = ${item} `;
console.log(`ASSERT`, msg.bgRed);
}
},
timer: (method, method_name) => {
console.time(`Timer ${method_name}()`);
method();
console.timeEnd(`Timer ${method_name}()`);
}
};

exports.log = log;
exports.default = _log;
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _log, {log} from './logdash'
import _log, {log} from './index'

export {log}
export default _log

0 comments on commit 1a0990d

Please sign in to comment.