         credentials.host = couch.host ? '127.0.0.1'
         credentials.port = couch.port ? '5984'
         credentials.db = couch.name ? 'cozy'
-        if couch.username? and couch.password?
+        if logCouchdb[0]? and logCouchdb[1]?
             credentials.auth = \
-                    {username: couch.username, password: couch.password}
+                    {username: logCouchdb[0], password: logCouchdb[1]}
 
     return credentials
 

cradle = require 'cradle'

setup_credentials = ->
    #default credentials
    credentials = {
        host : 'localhost',

        db: 'cozy'
    }

    logCouchdb = initLogCouchdb()

    # credentials retrieved by environment variable
    if process.env.VCAP_SERVICES?
