mixu / minilog

Lightweight client & server-side logging with Stream-API backends
http://mixu.net/minilog/
Other
380 stars 51 forks source link

Error: Warning: .format() is deprecated in Minilog v2! #7

Closed nevf closed 11 years ago

nevf commented 11 years ago

Using the Documented example:

var Minilog = require('minilog'),
    consoleBackend = Minilog.backends.nodeConsole;
Minilog.pipe(consoleBackend).format(consoleBackend.formatClean);

I get: [Error: Warning: .format() is deprecated in Minilog v2! Use .pipe(formatter).pipe(final) instead.]

It isn't clear to me what 'final' should be.

mixu commented 11 years ago

Hi, sorry - I've been working on Minilog v2 and updating the docs has taken a while.

The new docs are now online at http://mixu.net/minilog/

To answer your question, here's how you can do this:

var Minilog = require('minilog');
Minilog
  .pipe(Minilog.backends.console.formatClean)
  .pipe(Minilog.backends.console); 

var log = require('minilog')('app');
log.error('Hello world');

e.g. instead of a special cased .format(), just use pipe().

Edit: .pipe(Minilog.backends.console.formatClean), not .pipe(Minilog.backends.formatClean) as I originally wrote.

nevf commented 11 years ago

I've updated my code as follows:

var Minilog = require('minilog');
Minilog
  .pipe(Minilog.backends.formatClean)   // Exception occurs here
  .pipe(Minilog.backends.console); 

var mlog = require('minilog')('clibu_db');
mlog.info( 'Hello Minilog' );    

and am getting:

[TypeError: Cannot call method 'emit' of undefined]
TypeError: Cannot call method 'emit' of undefined
    at Transform.pipe (S:\Apps\nodejs\node_modules\minilog\lib\common\transform.js:28:8)
    at Function.<anonymous> (S:\Apps\nodejs\node_modules\minilog\lib\common\minilog.js:22:14)
    at Function.pipe (S:\Apps\nodejs\node_modules\minilog\lib\index.js:15:20)
    at Object.<anonymous> (S:\Apps\nodejs\clibu\scripts\clibu_db.js:46:4)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:31)
    at Function._load (module.js:311:12)
    at Module.require (module.js:359:17)
    at require (module.js:375:17)

I am using Minilog V2.0.1

Update: Changed to:

.pipe(Minilog.backends.console.formatClean)

resolved this.

mixu commented 11 years ago

Yeah, sorry about that - I'll correct the example above. Looks like the documentation site had the right Minilog.backends.console.* for the formatter.