Skip to content

Commit

Permalink
Merge pull request #70 from Download/fix/69-function-is-printed-inste…
Browse files Browse the repository at this point in the history
…ad-of-logger-name

Fixes #69 Function is printed instead of logger name
  • Loading branch information
Download authored Sep 14, 2021
2 parents 2aa3419 + 3791d8a commit 81c93fc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ can download it from here.

> `ulog.min.js` lazy loads `ulog.lazy.min.js` on demand, so make sure to include both files in your download
* [full.min.js](https://unpkg.com/[email protected]/full.min.js) (~5.7kB minified and gzipped)
* [full.min.js](https://unpkg.com/[email protected]/full.min.js) (~5.6kB minified and gzipped)

> Full bundle, no lazy loading
Expand Down
33 changes: 22 additions & 11 deletions mods/formats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ var parse = require('kurly/parse')
var pipe = require('kurly/pipe')
var grab = require('../../core/grab')
var console = require('../channels/console')
var makeStatic = require('./utils').makeStatic
var makeStaticPipe = require('./utils').makeStaticPipe
var firefox = require('../colors/utils').firefox
var applyFormatting = require('./apply-formatting')
var applyAlignment = require('./apply-alignment')

Expand Down Expand Up @@ -64,9 +63,8 @@ module.exports = {
.map(toTag)
.filter(skip)
.reduce(function(r,fmt){
var msg = makeStatic(fmt)
return applyFormatting(rec, fmt, msg, r)
}, [''])
return applyFormatting(rec, fmt, fmt, r)}
, [''])
// apply alignment if needed
applyAlignment(rec, args)
// bind the output and arguments to the log method
Expand All @@ -77,7 +75,19 @@ module.exports = {
} else {
return makeDynamicPipe(output, method, rec, line)
}
}
}

function makeStaticPipe(output, method, rec, args) {
return Object.defineProperty({}, 'out', {
get: function(){
return method.bind.apply(method,
[output].concat(firefox && (rec.level === 'trace') ? [] : args.map(function(arg){
return typeof arg == 'function' ? arg() : arg
})
))
}
}).out
}

function makeDynamicPipe(output, method, rec, line) {
// set up a dynamic pipeline as a function
Expand All @@ -101,11 +111,12 @@ module.exports = {
}})(rec)
}

function toTag(node) {return (
!node || !node.tag ? node :
node.tag
)}
function toTag(node) {
return !node || !node.tag ? node : node.tag
}

function skip(tag){return (typeof tag != 'string') || tag.trim().length}
function skip(tag){
return (typeof tag != 'string') || tag.trim().length
}
},
}
19 changes: 0 additions & 19 deletions mods/formats/utils.browser.js

This file was deleted.

8 changes: 0 additions & 8 deletions mods/formats/utils.js

This file was deleted.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"./mods/config/watch.js": "./mods/config/watch.browser.js",
"./mods/levels/default.js": "./mods/levels/default.browser.js",
"./mods/formats/aligned.js": "./mods/formats/aligned.browser.js",
"./mods/formats/default.js": "./mods/formats/default.browser.js",
"./mods/formats/utils.js": "./mods/formats/utils.browser.js"
"./mods/formats/default.js": "./mods/formats/default.browser.js"
},
"keywords": [
"ulog",
Expand Down

0 comments on commit 81c93fc

Please sign in to comment.