1602 / jugglingdb

Multi-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
http://1602.github.io/jugglingdb/
2.05k stars 241 forks source link

Adjust logging levels #401

Open alexiskattan opened 10 years ago

alexiskattan commented 10 years ago

Hi there,

Is there a way to adjust the logging levels of what is outputted from the database.

On my local machine and on heroku the logs have a lot of this:

2014-05-04T21:43:01.113622+00:00 app[web.1]: SELECT * FROM "People" WHERE "id" = 123 LIMIT 1 [3 ms]

Which is fine for some things, but it would be really nice to be able to reduce the log level s so I can find another bug from the logs.

Is there a way to do this?

Thanks for your help. I really like this platform.

alexiskattan commented 10 years ago

btw, I tried the app.enable 'log actions' I also saw, this Logger support (app.set('quiet', true) now forces logger to log in log/ENV.log here but I couldn't figure out what to do to test that out.

randunel commented 10 years ago

Later edit: The following only apply if you are also using compoundjs:

Have you tried adding app.set('quiet', true); in config/environment.js? Anyway, if you only want to suppress the database logs, you can add log: false in your database config in config/database.js

alexiskattan commented 9 years ago

@randunel Hi again. Been a while. Wheew! Im still looking to get not log all the db queries. I tried adding log: false in config/database.coffee but it is still logging...

module.exports =

development:
    driver: 'postgres'
    host:   'XXX'
    port:   111
    username: 'XXX'
    password: 'XXX'
    database: 'XXX'
    log: false

test:
    driver: "memory"
    database: 1
    log: false

production:
    driver: 'postgres'
    host: 'XXX'
    database: 'XXX'
    username: 'XXX'
    port: 111
    password: 'XXX'
    log: false
alexiskattan commented 9 years ago

After a bit of playing with it, this seems to work. If anyone is interested:

my_log = (str, startTime) ->
    m = Date.now() - startTime
    console.log "#{str} [#{m}ms]"

c.models.[YourModel].schema.log = my_log