Skip to content

Commit

Permalink
Merge pull request #41 from achohq/color
Browse files Browse the repository at this point in the history
Add new colors
  • Loading branch information
Kikobeats authored Sep 15, 2017
2 parents f569b40 + 7aad823 commit cdbc622
Show file tree
Hide file tree
Showing 33 changed files with 390 additions and 386 deletions.
281 changes: 134 additions & 147 deletions README.md

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions component.json

This file was deleted.

Binary file modified docs/images/00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/resume.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 0 additions & 18 deletions examples/formatter.js

This file was deleted.

56 changes: 21 additions & 35 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,63 @@
'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
return start
}
})()

var messageTimeout = (function () {
const messageTimeout = (function () {
return function (level, message, logger, time) {
setDateout(function () {
logger[level](message)
}, new Date().add({seconds: getStep(0.8)}))
}
})()

var lineBreakTimeout = (function () {
const lineBreakTimeout = (function () {
return function (time) {
setDateout(function () {
console.log()
}, new Date().add({seconds: getStep(time || 0.2)}))
}
})()

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)

Expand All @@ -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)
23 changes: 23 additions & 0 deletions examples/interpolation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

const acho = require('..')
const log = acho()

console.log()

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: {
foo: 'bar',
arr: [1, 2, 3, 4, 5]
}
})
31 changes: 5 additions & 26 deletions examples/levels.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
'use strict'

var Acho = require('..')
var acho = Acho({
diff: true,
timestamp: 1000,
upperCase: true,
context: 'generated'
// keyword: 'symbol'
})

var levels = Object.keys(acho.types)

var fixtureObj = {
foo: 'bar',
hello: 'world'
}

var fixtureArr = [1, 2, 3, 4, 5]

acho.debug('%j', fixtureObj)
acho.debug(fixtureObj)
acho.debug(fixtureArr)
const acho = require('acho')

levels.forEach(function (level) {
setInterval(function () {
acho[level]('This is a auto-generated ' + level + ' message')
acho[level](fixtureObj)
}, 1000)
const log = acho()
const types = Object.keys(log.types)
types.forEach(type => {
log[type]('hello world')
})
16 changes: 16 additions & 0 deletions examples/skin-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const acho = require('acho')
const skinCli = require('acho-skin-cli')

const log = acho({
types: skinCli,
keyword: 'symbol'
})

console.log()

const types = Object.keys(log.types)
types.forEach(type => {
log[type]('hello world')
})
15 changes: 15 additions & 0 deletions examples/skin-syslog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

const acho = require('acho')
const skinCli = require('acho-skin-syslog')

const log = acho({
types: skinCli
})

console.log()

const types = Object.keys(log.types)
types.forEach(type => {
log[type]('hello world')
})
29 changes: 29 additions & 0 deletions examples/trace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

const Acho = require('..')
const acho = Acho({
diff: true,
trace: 1000
// upperCase: true,
// keyword: 'symbol'
})

const levels = Object.keys(acho.types)

const fixtureObj = {
foo: 'bar',
hello: 'world'
}

const fixtureArr = [1, 2, 3, 4, 5]

acho.debug('%j', fixtureObj)
acho.debug(fixtureObj)
acho.debug(fixtureArr)

levels.forEach(function (level) {
setInterval(function () {
acho[level]('This is a auto-generated ' + level + ' message')
acho[level](fixtureObj)
}, 1000)
})
9 changes: 9 additions & 0 deletions examples/uppercase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

const acho = require('acho')

const log = acho({upperCase: true})
const types = Object.keys(log.types)
types.forEach(type => {
log[type]('hello world')
})
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
'use strict'
require('coffee-script/register')
module.exports = require('./lib/Acho')
19 changes: 6 additions & 13 deletions lib/Acho.coffee
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
'use strict'

DEFAULT = require './Default'
CONST = require './Constants'
DEFAULT = require './Default'

Acho = (params = {}) ->
return new Acho params unless this instanceof Acho
Acho = (opts = {}) ->
return new Acho opts unless this instanceof Acho

acho = Object.assign({}, DEFAULT, params)
acho = Object.assign({}, DEFAULT(), opts)
acho.diff = [] if acho.diff
acho[key] = value for key, value of acho

acho.messages = do ->
messages = {}
for type of acho.types
messages[type] = params.messages?[type] or []
messages[type] = opts.messages?[type] or []
acho[type] = acho.generateTypeMessage type
messages

Expand All @@ -30,11 +29,5 @@ Acho = (params = {}) ->

acho

Acho.skin = (skinFn) ->
skin = skinFn(CONST)
(params = {}) ->
Acho(Object.assign({}, params, skin))

Acho.defaults = DEFAULT

module.exports = Acho
module.exports.constants = CONST
2 changes: 1 addition & 1 deletion lib/Constants.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ figure =
module.exports =
DECORATE_COUNTER_ZERO_N : 4
UNMUTED : 'all'
LINE_COLOR : 'gray'
LINE_COLOR : ['gray']
SYMBOL_KEYWORD : 'symbol'
MUTED : 'muted'
FIGURE : figure[process.platform is 'win32']
Loading

0 comments on commit cdbc622

Please sign in to comment.