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

Assign Logger Per Client

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.1.0
    • Affects Version/s: 2.0.6
    • Component/s: None
    • Fully Compatible

      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?

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

              Created:
              Updated:
              Resolved: