commenthol / debug-level

debug with levels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prevent JSON output

dcsan opened this issue · comments

commented

logs are unreadable as JSON output.
I'm running with these flags:

DEBUG_COLORS=true DEBUG_JSON=false NODE_ENV=astro nodemon src/server.ts

is there anyway to really make sure to nuke the json formatting when creating the object/instance?

when I do a normal console.log I get nice readable debug but with this library I just get this eyesore:

image

commented

the reason display is like this is because my NODE_ENV is not called exactly development
anything else and the logging functions default to "unreadable for humans" mode.

I tried both false and DEBUG_JSON=0 - but this doesn't work either.

DEBUG_JSON=false ...
DEBUG_JSON=0 ....

are there any other options or should I just use console.log ?

since these options don't work, can this lib work with other logging output formatters? tap etc?

commented

also tried this at the start of the app, no changes to output

const Log = require('debug-level')
Log.options({
  json: false  /// also tried true - no change
})
commented

also tried as %j

clog.error('error adding role %j', err)

maybe the mistmatch here is i'm trying to log an objects, but i want nicely formatted JSON not the wall-o-text kind.

is there a way to get objects to output with indentation etc? like json.dumps(obj, null, 4)

DEBUG_SPLIT_LINE=true should give you the expected behavior.
e.g.

DEBUG_COLORS=true DEBUG_JSON=false DEBUG_SPLIT_LINE=true NODE_ENV=astro node examples/levels