Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-214

Node.js native driver logger has incorrect and very partial documentation

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      This case is probably a combination of a driver bug, enhancement request and documentation issues.
      However, all boils down to that trying to connect a logger to the node.js native driver is a very challenging.
      1. The documentation is simply wrong regadring how to connect a mongo (http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html). In the documentation the logger option for connect function appears under options.server, but it is actually under options.db.
      2. The documentation doesn't say anywhere that the logger must have the properties logger.doDebug=true and logger.doError=true. Without it the logger simply doesn't work and I don't see a way to guess it.
      3. The logging passes an object as the second parameter to the log functions, which sometimes is a bson object with binary data. I suppose that any implementation that tries to connect the logger will call JSON.stringify(obj) in order to serialize the object to the log. This call fails without any warning when trying to serialize a bson object. I don't see a reason to log bson objects, but it does being sent from time to time and requires a hack to not try to serialize those objects.
      4. The implementation is strange and as far as I know not consistent with common logging framework in javascript world. Also there is no documentation explaining the required API, I still not sure what is the object parameter (why logging an object and not a string?). It therefore requires implementing a custom adapter which is not that great. It would be nice if it was expecting something standard like Winston (https://www.npmjs.org/package/winston) or even the simple log (https://npmjs.org/package/log).

            Assignee:
            Unassigned Unassigned
            Reporter:
            emoshe Elad Moshe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: