diff --git a/examples/index.js b/examples/index.js index f02f69b..2567e14 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1,31 +1,31 @@ 'use strict' require('date-utils') -var Acho = require('..') -var setDateout = require('set-dateout') +const acho = require('..') +const setDateout = require('set-dateout') -var base = Acho({}) +const base = acho({}) -var diff = Acho({ +const diff = acho({ diff: true }) -var label = Acho({ +const label = acho({ align: false, keyword: 'worker#1' }) -var production = Acho({ - color: false, - align: false +const visit = acho({ + types: require('acho-skin-cli'), + keyword: 'symbol' }) -var visit = Acho({ - keyword: 'visit' +const log = acho({ + keyword: 'log' }) -var getStep = (function () { - var start = 0 +const getStep = (function () { + let start = 0 return function (value) { if (value) start += value else ++start @@ -33,7 +33,7 @@ var getStep = (function () { } })() -var messageTimeout = (function () { +const messageTimeout = (function () { return function (level, message, logger, time) { setDateout(function () { logger[level](message) @@ -41,7 +41,7 @@ var messageTimeout = (function () { } })() -var lineBreakTimeout = (function () { +const lineBreakTimeout = (function () { return function (time) { setDateout(function () { console.log() @@ -49,18 +49,15 @@ var lineBreakTimeout = (function () { } })() -messageTimeout('info', 'Hackable', base) -messageTimeout('debug', 'Logging', base) -messageTimeout('warn', 'for NodeJS and Browser', base) +console.log() +messageTimeout('info', 'The', base) +messageTimeout('debug', 'Hackable', base) +messageTimeout('warn', 'Log', base) messageTimeout('error', 'in less than', base) messageTimeout('fatal', '10KB!.', base) lineBreakTimeout(1) -messageTimeout('info', 'Do you wanna to know more?', base) - -lineBreakTimeout() - messageTimeout('debug', 'support diff', diff) messageTimeout('debug', 'between messages', diff) @@ -71,21 +68,10 @@ messageTimeout('warn', 'easily', label) lineBreakTimeout() -messageTimeout('error', 'automatically color and align disabled', production) -messageTimeout('error', 'under production scenario', production) - -lineBreakTimeout() - -messageTimeout('debug', 'and more more more...', base) - -lineBreakTimeout() +messageTimeout('info', 'pretty serialization', log) -messageTimeout('debug', 'string interpolation', base) -messageTimeout('debug', 'logs align', base) -messageTimeout('info', 'custom levels and transports', base) -messageTimeout('info', 'object serialization', base) -messageTimeout('info', {foo: 'bar', hello: 'world'}, base) +messageTimeout('info', { foo: 'bar', hello: 'world' }, log) lineBreakTimeout() -messageTimeout('debug', 'https://github.com/Kikobeats/acho', visit) +messageTimeout('success', 'See more at https://github.com/Kikobeats/acho', visit) diff --git a/examples/interpolation.js b/examples/interpolation.js index 5b265b6..9bb272f 100644 --- a/examples/interpolation.js +++ b/examples/interpolation.js @@ -1,15 +1,19 @@ 'use strict' -var Acho = require('..') -var acho = Acho() +const acho = require('..') +const log = acho() -acho.info('formatting plain text: hello world') -acho.info('formatting with number interpolation %d', 123) -acho.info('formatting with float interpolation %d', 3.14) -acho.info('formatting with string interpolation %s', 'hello world') -acho.info('formatting with object interpolation %j', {hello: 'world', foo: 'bar'}) +console.log() -acho.info('formatting with object interpolation %J', { +log.info('format text', 'hello world') +log.info('format number interpolation %d', 123) +log.info('format float interpolation %d', 3.14) +log.info('format string interpolation %s', 'hello world') +log.info('format object interpolation %j', { + hello: 'world', foo: 'bar' +}) + +log.info('format beauty object interpolation %J', { hello: 'world', foo: 'bar', deep: { diff --git a/examples/levels.js b/examples/levels.js index 7d21535..074ad2d 100644 --- a/examples/levels.js +++ b/examples/levels.js @@ -1,22 +1,22 @@ 'use strict' -var Acho = require('..') -var acho = Acho({ +const Acho = require('..') +const acho = Acho({ diff: true, timestamp: 1000, - upperCase: true, + // upperCase: true, context: 'generated' // keyword: 'symbol' }) -var levels = Object.keys(acho.types) +const levels = Object.keys(acho.types) -var fixtureObj = { +const fixtureObj = { foo: 'bar', hello: 'world' } -var fixtureArr = [1, 2, 3, 4, 5] +const fixtureArr = [1, 2, 3, 4, 5] acho.debug('%j', fixtureObj) acho.debug(fixtureObj)