Git Product home page Git Product logo

Comments (5)

kenperkins avatar kenperkins commented on July 23, 2024

The lack of logging has been giving me a fair amount of grief, so I've been toying with something like yay:

var Client = exports.Client = function (options) {
  events.EventEmitter2.call(this, { delimiter: '::', wildcard: true });
  this.config = options || {};

  // Setup logging
  this.log = options.log || function() {};
  this.on('log', this.log);
};

Elsewhere simply:

this.emit('log', 'verbose', 'Starting Request', requestPayload);

What do you think? I'm happy to get started on something because it would greatly assist when debugging and developing new features. I want something I can integrate with winston, but doesn't actually require any specific logging framework.

from pkgcloud.

rosskukulinski avatar rosskukulinski commented on July 23, 2024

I would appreciate the ability to log out to winston from the library. +1

from pkgcloud.

indexzero avatar indexzero commented on July 23, 2024

@kenperkins That could work, really though all we need to do is emit the options we pass to request each time as in nodejitsu-api: https://github.com/nodejitsu/nodejitsu-api/blob/master/node.js/lib/client/client.js#L187

from pkgcloud.

kenperkins avatar kenperkins commented on July 23, 2024

Do you leave it up to the caller to implement client.on('xxx') ? or should it be passed into the client as an option?

Is everything just a debug message? do we have any need of different levels of verbosity within pkgcloud proper?

For example, we could do this.emit('log::debug', message, opts) or we could do this.emit('debug::request', opts) but that could make multiple levels complicated.

from pkgcloud.

kenperkins avatar kenperkins commented on July 23, 2024

I've implemented a minimal amount of logging in core/client and in a few places in the rackspace/openstack providers.

example:

var client = pkgcloud.providers.rackspace.compute.createClient({ ... });

client.on('log::*', function(message, meta) {
    // use your logging info here
});

Was introduced with 41e96d4

from pkgcloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.