Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-990

Assign Logger Per Client

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.0.6
    • 2.1.0
    • None
    • Fully Compatible

    Description

      When using the ruby mongo driver (2.0.6), you currently have to assign the logger and logger level on a Mongo singleton, like this:

      Mongo::Logger.logger = other_logger
      Mongo::Logger.logger.level = Logger::WARN

      The Mongo singleton is problematic for us. Our application contains 3 isolated services, each with its own mongo database and logging system. We assumed the Mongo::Client would be an isolated class, and we could assign individual loggers, like in this contrived example...

      mongo1 = Mongo::Client.new("mongodb://127.0.0.1:27017/db1")
      mongo1.logger = some_logger1

      mongo2 = Mongo::Client.new("mongodb://127.0.0.1:27017/db2")
      mongo2.logger = some_logger2

      mongo3 = Mongo::Client.new("mongodb://127.0.0.1:27017/db3")
      mongo3.logger = some_logger3

      ... but it turns out we cannot.

      Any chance the client can be refactored such that each client can have it's own logger assigned?

      Attachments

        Activity

          People

            durran.jordan@mongodb.com Durran Jordan
            eriklott Erik Lott
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: