From 17c92ed5105748b88aa57b51d46ab3d95cf831e7 Mon Sep 17 00:00:00 2001 From: Stijn de Witt Date: Wed, 27 Dec 2017 14:57:00 +0100 Subject: [PATCH] 2.0.0-beta.2: API improvements * Loggers are functions now. Supports debug-style API * Logger function defaults to level DEBUG * Logger function accepts a level name as first parameter * Added aliases 'verbose' and 'silly' for levels 'log' and 'trace', respectively * Ulog now supports hooks for logger extension and formatters * Ulog should now be a drop-in replacement for [debug](https://npmjs.com/package/debug) New in beta.2: In node version, file descriptor is exposed on console.fd so it can be used in extensions. ## Backward compatible v2 Should be a backward-compatible release. But possibly some (very) old browsers are no longer supported because of the use of Function.prototype.name. Tested on Internet Explorer 11, Edge 41, Opera 49, Chrome 63. Please test before upgrading and report any issues in the [issue tracker](https://github.com/download/ulog/issues). Not tested in Safari because I do not have access to a Mac. Help in testing welcome! --- node.js | 1 + package.json | 1 + ulog.js | 2 +- ulog.min.js | 2 +- ulog.umd.js | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/node.js b/node.js index 453c91f..863cae9 100644 --- a/node.js +++ b/node.js @@ -12,6 +12,7 @@ if (typeof fd == 'number') { logger = function(){stream.write(util.format.apply(this, arguments) + '\n')} c = {error:logger, warn:logger, info:logger, log:logger, trace:logger} } +if (fd !== undefined) c.fd = fd log.extends.push(function(o,p){ // makes Node behave like browsers diff --git a/package.json b/package.json index 293bb2f..86b5a47 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.0.0-beta.1", "description": "Microscopically small universal logging library", "main": "node.js", + "unpkg": "ulog.min.js", "browser": "browser.js", "scripts": { "clean": "rimraf ulog.umd.js && rimraf ulog.min.js", diff --git a/ulog.js b/ulog.js index 3a4da1f..e656e8f 100644 --- a/ulog.js +++ b/ulog.js @@ -44,7 +44,7 @@ function create(n,r) { function extend(o,p,l) { if (o.log) return o.NONE = 0 - o.ulog = {version:'2.0.0-beta.1'} + o.ulog = {version:'2.0.0-beta.2'} for (var key in LVL) {o[key] = LVL[key]} Object.defineProperty(o, 'level', { get: function(){return l !== undefined ? l : p && p.level}, diff --git a/ulog.min.js b/ulog.min.js index 498fb5f..83fdbf2 100644 --- a/ulog.min.js +++ b/ulog.min.js @@ -1 +1 @@ -!function(e,n,o){"function"==typeof define&&define.amd?define(n,[],o):e[n]=o()}(this,"ulog",function(){"use strict";function log(e){return e?mods[e]||(mods[e]=extend(create(e),log)):extend(log)}function create(n,r){return eval("r = {'"+n+"': function() {var a = [].slice.call(arguments), m = a.length > 1 && names[a[0]] ? a.shift() : 'debug'; for (var i=0; i=0&&r<=6&&(o=r)}if(patch(e),!n)for(mod in mods)patch(mods[mod])}}),patch(e);for(var r=0;r 1 && names[a[0]] ? a.shift() : 'debug'; for (var i=0; i=0&&r<=6&&(o=r)}if(patch(e),!n)for(mod in mods)patch(mods[mod])}}),patch(e);for(var r=0;r