-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgraded formatting to kurly v2 which supports static pipes * Implemented outputs as Kurly formats * Include kurly in ulog as standard * Added colors * Added alignments * Lazy loading
- Loading branch information
Showing
77 changed files
with
1,510 additions
and
738 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/dist | ||
/node_modules | ||
/ulog.min.js | ||
/ulog.lazy.min.js | ||
/.nyc_output | ||
/test.min.js | ||
/full.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var ulog = module.exports = require('./core') | ||
ulog.use([ | ||
require('./mods/config'), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var merge = module.exports = function(result, obj) { | ||
for (var o in obj) { | ||
if ((typeof obj[o] == 'object') && (Object.getPrototypeOf(obj[o]) === Object.prototype)) { | ||
if (! (o in result)) result[o] = {} | ||
if ((typeof result[o] == 'object') && (Object.getPrototypeOf(obj[o]) === Object.prototype)) { | ||
merge(result[o], obj[o]) | ||
} else { | ||
result[o] = obj[o] | ||
} | ||
} else { | ||
result[o] = obj[o] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
"lvl name:22 date:yy/mm/dd perf" | ||
|
||
"console file:./log.output url:https://deze-auto-kopen.nl component:( with nested components )" | ||
|
||
|
||
function parse(str) { | ||
var tag, result = [] | ||
if (str || (str === '')) { | ||
while (tag = nextTag(str)) { | ||
var before = str.substring(0, tag.index) | ||
if (before) result.push(before) | ||
result.push({ | ||
name: tag.name, | ||
text: tag.text, | ||
ast: parse(tag.text) | ||
}) | ||
str = str.substring(tag.end + 1) | ||
} | ||
if (str) result.push(str) | ||
} | ||
return result | ||
} | ||
|
||
function nextTag(str) { | ||
var match = str.match(/\{[_a-zA-Z][_a-zA-Z0-9]*([^_a-zA-Z0-9].*)?\}/) | ||
var result | ||
if (match) { | ||
var name = match[1] ? match[0].substring(1, match[0].indexOf(match[1])) : match[0].substring(1, match[0].indexOf('}')) | ||
result = { name: name, index: match.index, end: -1, text: '' } | ||
// loop through the string, parsing it as we go through it | ||
var esc = false | ||
var open=1 // we already found one open brace | ||
for (var i=match.index+name.length+1; i<str.length; i++) { | ||
var token = str[i] | ||
if (esc) { | ||
token = (token == 'n') ? '\n' : | ||
(token == 't') ? '\t' : | ||
(token == '{') || | ||
(token == '}') || | ||
(token == '\\') ? token : | ||
'\\' + token // unrecognized escape sequence is ignored | ||
} | ||
else { | ||
if (token === '{') { | ||
open++ | ||
} | ||
if (token === '}') { | ||
open-- | ||
if (!open) { | ||
result.end = i | ||
break | ||
} | ||
} | ||
if (token === '\\') { | ||
esc = true | ||
continue | ||
} | ||
if (!result.text && (token.search(/\s/)===0)) { | ||
continue | ||
} | ||
} | ||
result.text += token | ||
esc = false | ||
} | ||
} | ||
return result | ||
} | ||
|
||
/** | ||
* Compiles an abstract syntax tree into a function | ||
* | ||
* @param {Array<String|Object>} ast An abstract syntax tree created with `parse` | ||
* @param {Object} tags An object of tags keyed by tag name | ||
* @param {Function} parent Optionally, a compiled parent function for the ast | ||
* | ||
* @returns An array, possibly empty but never null or undefined. | ||
*/ | ||
function compile(ast, tags, parent) { | ||
if (process.env.NODE_ENV != 'production') { | ||
log.debug('compile', ast, tags, parent) | ||
if ((ast === undefined) || (ast === null)) throw new Error('parameter `ast` is required') | ||
if (! Array.isArray(ast)) throw new Error('parameter `ast` must be an array') | ||
if ((tags === undefined) || (tags === null)) throw new Error('parameter `tags` is required') | ||
if (typeof tags != 'object') throw new Error('parameter `tags` must be an object') | ||
} | ||
|
||
// recursively compile the ast | ||
var nodes = ast.map(function(n){ | ||
return typeof n == 'string' | ||
? n : | ||
compile(n.ast, tags, | ||
tags[n.name] ? tags[n.name](n) : | ||
tags['*'] ? tags['*'](n) : | ||
undefined | ||
) | ||
}) | ||
|
||
// create the result function | ||
var result = function(rec) { | ||
// clone rec into res | ||
var res = {} | ||
for (k in rec) res[k] = rec[k] | ||
// get the result children | ||
res.children = nodes.reduce(function(r, n){ | ||
if (typeof n == 'function') n = n(rec) | ||
r.push.apply(r, Array.isArray(n) ? n : [n]) | ||
return r | ||
}, []) | ||
// invoke parent if we have it | ||
return parent ? parent(res) : res.children | ||
} | ||
if (process.env.NODE_ENV != 'production') { | ||
log('compile', ast, tags, parent, '=>', '[Function]') | ||
} | ||
return result; | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// var grab = require('../../core/grab') | ||
// var palette = require('./utils').palette | ||
// var levels = require('./utils').levels | ||
|
||
var boolean = require('../props/boolean') | ||
|
||
module.exports = { | ||
use: [ | ||
require('../props'), | ||
], | ||
|
||
settings: { | ||
align: { | ||
config: 'log_align', | ||
prop: boolean() | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var ZWSP = ''; // zero-width space | ||
var firefox = require('../colors/utils').firefox | ||
|
||
module.exports = { | ||
// alignment depends on color format specifiers in the browser | ||
hasAlign: require('../colors/utils').hasColor, | ||
|
||
specifier: { | ||
error: '%c%s%c%s', | ||
warn: '%c%s%c%s', | ||
info: '%c%s%c%s', | ||
log: '%c%s%c%s', | ||
debug: '%c%s%c%s', | ||
trace: '%c%s%c%s', | ||
}, | ||
|
||
args: { | ||
error: ['padding-left:0px', ZWSP, 'padding-left:0px', ZWSP], | ||
warn: ['padding-left:' + (firefox ? '12' : '0') + 'px', ZWSP, 'padding-left:0px', ZWSP], | ||
info: ['padding-left:' + (firefox ? '12' : '10') + 'px', ZWSP, 'padding-left:0px', ZWSP], | ||
log: ['padding-left:' + (firefox ? '12' : '10') + 'px', ZWSP, 'padding-left:0px', ZWSP], | ||
debug: ['padding-left:' + (firefox ? '12' : '10') + 'px', ZWSP, 'padding-left:0px', ZWSP], | ||
trace: ['padding-left:0px', ZWSP, 'padding-left:0px', ZWSP], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var console = require('../channels/console') | ||
module.exports = { | ||
hasAlign: function(output){return output === console}, | ||
specifier: { | ||
trace: '\n' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = (typeof console != 'undefined') && console |
Oops, something went wrong.