vs loglevel
+This page compares ulog
to loglevel
.
Open devtools
+Open the browser developer tools (F12).
+diff --git a/README.md b/README.md index 0b8d213..64e646c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ulog v2.0.0-beta.16 +# ulog v2.0.0-beta.17 ### The Universal Logger [![npm](https://img.shields.io/npm/v/ulog.svg)](https://npmjs.com/package/ulog) @@ -8,14 +8,14 @@ . -![logo](https://unpkg.com/ulog@2.0.0-beta.16/ulog.png) +![logo](https://unpkg.com/ulog@2.0.0-beta.17/ulog.png) ## The logger for javascript applications `ulog` is *the* logger for Javascript applications. It's universal, meaning it runs everywhere. You can use `ulog` in your Express server application running on Node JS just as well as in your React single page application running in the browser. It just works. -![screenshot](https://unpkg.com/ulog@2.0.0-beta.16/screenshot.jpg) +![screenshot](https://unpkg.com/ulog@2.0.0-beta.17/screenshot.jpg) ## Features @@ -130,7 +130,7 @@ log('Logging is easy') If you want, you can import `ulog` with a script tag: ```html - + @@ -146,12 +146,12 @@ log('Logging is easy!') If you want the file for the browser to include in your project yourself, you can download it from here. -* [ulog.min.js](https://unpkg.com/ulog@2.0.0-beta.16/ulog.min.js) (~2.7kB minified and gzipped) -* [ulog.lazy.min.js](https://unpkg.com/ulog@2.0.0-beta.16/ulog.lazy.min.js) (~4.3kB minified and gzipped) +* [ulog.min.js](https://unpkg.com/ulog@2.0.0-beta.17/ulog.min.js) (~2.7kB minified and gzipped) +* [ulog.lazy.min.js](https://unpkg.com/ulog@2.0.0-beta.17/ulog.lazy.min.js) (~4.3kB minified and gzipped) > `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/ulog@2.0.0-beta.16/full.min.js) (~5.7kB minified and gzipped) +* [full.min.js](https://unpkg.com/ulog@2.0.0-beta.17/full.min.js) (~5.7kB minified and gzipped) > Full bundle, no lazy loading @@ -613,12 +613,12 @@ messages at these higher levels are indented a bit more than the other messages, making the logging harder to read. This can be clearly seen in the screenshot from `ulog` v2.0.0-beta-11, which did not yet have alignment: -![screenshot](https://unpkg.com/ulog@2.0.0-beta.16/screenshot-beta.11.jpg) +![screenshot](https://unpkg.com/ulog@2.0.0-beta.17/screenshot-beta.11.jpg) `ulog` now automatically adds some formatting that negates the extra indentation the messages at these higher levels get, so all messages are nicely aligned: -![screenshot](https://unpkg.com/ulog@2.0.0-beta.16/screenshot.jpg) +![screenshot](https://unpkg.com/ulog@2.0.0-beta.17/screenshot.jpg) You can control alignment with [config option `log_align`](#config-option-log_align). diff --git a/build.js b/build.js index 96e1b03..01585c5 100644 --- a/build.js +++ b/build.js @@ -44,6 +44,22 @@ var v = pkg.version fs.writeFileSync(file, data, 'utf8') log.info(`README.md (~${(data.length / 1024).toFixed(1)} kB)`) + file = path.resolve(__dirname, 'tutorial', 'index.html') + log(`Reading ${file}`) + data = fs.readFileSync(file, 'utf-8') + data = data.replace(/ulog@\d(\d)?\.\d(\d)?\.\d(\d)?(-[a-z]+\.\d(\d)?)?/g, `ulog@${v}`) + log(`Writing ${file}`) + fs.writeFileSync(file, data, 'utf8') + log.info(`tutorial/index.html (~${(data.length / 1024).toFixed(1)} kB)`) + + file = path.resolve(__dirname, 'vs', 'debug.html') + log(`Reading ${file}`) + data = fs.readFileSync(file, 'utf-8') + data = data.replace(/ulog@\d(\d)?\.\d(\d)?\.\d(\d)?(-[a-z]+\.\d(\d)?)?/g, `ulog@${v}`) + log(`Writing ${file}`) + fs.writeFileSync(file, data, 'utf8') + log.info(`vs/debug.html (~${(data.length / 1024).toFixed(1)} kB)`) + ulog('a:one').debug('A debug message') ulog('a:two').debug('A debug message') ulog('a:three').debug('A debug message') diff --git a/mods/config/watch.js b/mods/config/watch.js index bf37c0f..acbd3e2 100644 --- a/mods/config/watch.js +++ b/mods/config/watch.js @@ -7,10 +7,8 @@ var notify = require('./notify') module.exports = function(ulog) { var filename = path.resolve(ulog.get('log_config') || 'log.config') - console.info('watching ' + filename) try { fs.watch(filename, { persistent: false }, function() { - console.info(filename + ' changed. reading it again') read(ulog, function(cfg){ var changed = update(ulog.config, cfg) if (changed.length) notify(ulog, changed) diff --git a/package.json b/package.json index f3be7c5..746e6e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ulog", - "version": "2.0.0-beta.16", + "version": "2.0.0-beta.17", "description": "The universal logger", "main": "./ulog.js", "unpkg": "ulog.min.js", diff --git a/tutorial/index.html b/tutorial/index.html index aac72da..faa01c7 100644 --- a/tutorial/index.html +++ b/tutorial/index.html @@ -4,7 +4,7 @@
Open the browser developer tools (F12).
No output will be visible until you enable logging, by adding a
- configuration key to localStorage
. To enable logging
- in both debug
and ulog
, add this to localStorage
:
debug=*
-
- To add this to localStorage, you can use the developer tools (for Chrome, tab Application) - or in the Console tab, run this command:
-localStorage.setItem('debug', '*')
-
+ No output will be visible until you enable logging. To enable
+ logging in both debug
and ulog
, set
+ debug=*
.
You can do this using the developer tools GUI (tab Application in
+ Chrome), or in the Console tab run this command:
+ localStorage.setItem('debug', '*')
,
+ or you can press the button below:
Paragraph text
- Body text -Paragraph text
-Paragraph text
-Paragraph text
-Paragraph text
-Paragraph text
-You should get output like this:
+ +ulog
monitors the configYou may notice that debug
is not producing any output,
+ whereas ulog
is. That's because ulog
monitors
+ the configuration at runtime but debug
doesn't. So to get
+ debug
to pick up our configuration change, reload the
+ page (F5). Then, press both buttons again. This time, we can see
+ debug
and ulog
output side by side:
The output of ulog
and debug
is very similar.
+ Both loggers add the name of the logger to the message and both loggers
+ show some timing information. Also, both loggers use colors to produce
+ more clear output. But, there are actually more differences here than
+ initially meet the eye.
+
ulog
preserves the callstackOne big difference between debug
and ulog
+ is marked with arrows in the screenshot. ulog
preserves
+ the callstack, meaning file names and line numbers shown in the
+ console point to the client code. This is in big contrast to
+ debug
, which injects it's own formatting function in
+ the callstack, meaning all file names and line numbers point to that
+ function in the debug
minified source file. Not very
+ convenient!
ulog
has configurable formattingdebug
only allows some tweaks to it's formatting.
+ ulog
allows you to take full control of formatting.
+ You can change the format for all or some loggers using config
+ option log_format. For example, let's try adding the time to the
+ message. Set log_format=time lvl name perf
in the
+ devtools or press the button below:
This page compares ulog
to loglevel
.
Open the browser developer tools (F12).
+