Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger creation error #10

Open
wildart opened this issue Oct 20, 2013 · 4 comments
Open

Logger creation error #10

wildart opened this issue Oct 20, 2013 · 4 comments
Assignees

Comments

@wildart
Copy link

wildart commented Oct 20, 2013

I'm trying to create logger by running following code (node 0.10.17)

var co = require('cocaine')
var Logger = co.Service('logging')
L = new Logger(argv.app)
L.info("test")

it generates an error:

/home/test/test/node_modules/cocaine/lib/services/logging.js:32
    this.verbosity()
         ^
TypeError: Object #<EventEmitter> has no method 'verbosity'
    at EventEmitter.Logger [as __cls] (/home/art/Development/flood-bridge/node_modules/cocaine/lib/services/logging.js:32:10)
    at Object.<anonymous> (/home/art/Development/flood-bridge/bridge.js:21:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain [as _onTimeout] (module.js:497:10)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
@ghost ghost assigned diunko Oct 20, 2013
@diunko
Copy link
Member

diunko commented Oct 21, 2013

Ok, now. I clearly see that the right examples are missing. They are to be added some days this week.

Right away you can use services in a way like this: https://github.com/cocaine/cocaine-framework-nodejs/tree/development#make-use-of-cocaine-services

This one proved itself to be working:
https://github.com/cocaine/cocaine-framework-nodejs/blob/development/sample/app.http.js

@wildart
Copy link
Author

wildart commented Oct 22, 2013

I changed program as you recommended:

#!/usr/bin/node

var co = require('cocaine')
    , argv = require('optimist').argv
    , mp = require('msgpack')

var W, L

co.getServices(['logging'],function(Logger){

    L = new Logger(argv.app)
    W = new co.Worker(argv)

    W.on('test',function(stream){
        var msg
        L.info("Got request")
        stream.on('data',function(data){
            msg = data
            console.info('received:' + msg)
        })

        stream.on('end',function(){
            stream.write(mp.pack('respond:' + msg))
            stream.end()
        })
    })

    W.on('_terminate',function(){
        L.info('bridge terminated')
    })
    W.connect()
});

but still have an error during logger initialization:

/opt/cocaine/spool/test/node_modules/cocaine/node_modules/q/q.js:126
                    throw e;
                          ^
TypeError: object is not a function
    at /opt/cocaine/spool/test/test.js:11:9
    at /opt/cocaine/spool/test/node_modules/cocaine/lib/service.js:106:8
    at _fulfilled (/opt/cocaine/spool/test/node_modules/cocaine/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/opt/cocaine/spool/test/node_modules/cocaine/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/opt/cocaine/spool/test/node_modules/cocaine/node_modules/q/q.js:760:13)
    at /opt/cocaine/spool/test/node_modules/cocaine/node_modules/q/q.js:574:44
    at flush (/opt/cocaine/spool/test/node_modules/cocaine/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

And it is a logger initialization call again. Any clues?

@green13
Copy link

green13 commented May 5, 2015

Hi, I have a problem with logger.
I'm trying to add logger to my app (worker):

var cocaine = require('cocaine');
var cli = new cocaine.Client(); // ["localhost", 10053]
var L = new cli.Logger("farkleportal") 

L.connect(); // error

Error:

/var/spool/cocaine/farkleportal/node_modules/cocaine/lib/client/service.js:152
    (_this._client || client).resolve(_this._name, _resolveDone)
                              ^
TypeError: Object [object Object] has no method 'resolve'
    at _resolve (/var/spool/cocaine/farkleportal/node_modules/cocaine/lib/client/service.js:152:31)
    at EventEmitter.serviceConnect [as connect] (/var/spool/cocaine/farkleportal/node_modules/cocaine/lib/client/service.js:142:5)
    at EventEmitter.Logger.connect (/var/spool/cocaine/farkleportal/node_modules/cocaine/lib/client/logger.js:50:21)
    at Object.<anonymous> (/var/spool/cocaine/farkleportal/utils/logger.js:8:7)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

Cocaine module version: "0.4.1-6".

@diunko
Copy link
Member

diunko commented May 5, 2015

That's an inaccuracy in readme, since cli.Logger is a factory function, not a constructor. So, you can create logger like this:

var cocaine = require('cocaine');
var cli = new cocaine.Client(); // ["localhost", 10053]
var L = cli.Logger("farkleportal") 

L.connect(); 

See also https://github.com/cocaine/cocaine-framework-nodejs/blob/v0.4/sample/client.0.js or https://github.com/cocaine/cocaine-framework-nodejs/blob/v0.4/sample/client.1.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants