Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-3004

Create event-specific command logging components

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Unknown Unknown
    • None
    • None
    • None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      There could be a need for a user to only log specific command events, rather than any command event. For example, logging all commands may cause performance issues and thus user only wants to log failed commands. To address this issue, this ticket suggests adding the following logging components:

      • LogComponentCommandFailed: log the "failed" subset of all commands
      • LogComponentCommandStarted: log the "started" subset of all commands
      • LogComponentCommandSucceeded: log the "succeeded" subset of all commands

      The usage of this would be the following:

      	loggerOptions := options.
      		Logger().
      		SetSink(sink).
      		SetComponentLevel(options.LogComponentCommandFailed, options.LogLevelDebug).
      		SetComponentLevel(options.LogComponentCommandStarted, options.LogLeveInfo)
       
      	clientOptions := options.
      		Client().
      		ApplyURI("mongodb://localhost:27017").
      		SetLoggerOptions(loggerOptions)
      

      boris.dogadov@mongodb.com notes that "We don't want to overcomplicate things and have O(N) categories, where N is log messages."
       
      The original intention is for this is to filter logs during post-processing, i.e.

      func (logger *CustomLogger) Info(level int, msg string, _ ...interface{}) {
      	logger.mu.Lock()
      	defer logger.mu.Unlock()
       
      	if msg == "Command failed" {
      		// Log something
      	}
      }
      

      The Go Driver could make this easier by exporting helper constants in the mongo package for specific message types:

      	if msg == mongo.LogComponentCommandFailedMsg {
      		// Log something
      	}

      It may aslo be helpful to add a more granular filtering API to the log options, i.e. a "FilterEvents()" method.

      Attachments

        Activity

          People

            Unassigned Unassigned
            preston.vasquez@mongodb.com Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: