• Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.3.9
    • Affects Version/s: None
    • Component/s: None
    • None
    • 3
    • Iteration Telescope, Iteration U (Jan 27 - Feb 10)
    • Needed
    • Hide

      Now, users can log their custom messages by calling `log.info()` / `log.warn()` / log.error()` / log.fatal()` / log.debug()` in their scripts, e.g.:

      log.info('This is an info message');
      log.warn('Warning!'); 

      The custom log message will sequentially appear alongside internal mongosh messages, and will look similar to this:

      {"t":{"$date":"2025-01-06T16:14:23.023Z"},"s":"I","c":"MONGOSH","id":1000000012,"ctx":"shell-api","msg":"Loading file via load()","attr":{"nested":false,"filename":"/Users/alena.khineika/custom-logging.js"}}{"t":{"$date":"2025-01-06T16:14:23.041Z"},"s":"I","c":"MONGOSH-SCRIPTS","id":1000000054,"ctx":"custom-log","msg":"This is an info message"}{"t":{"$date":"2025-01-06T16:14:23.041Z"},"s":"W","c":"MONGOSH-SCRIPTS","id":1000000054,"ctx":"custom-log","msg":"Warning!"} 
      Show
      Now, users can log their custom messages by calling `log.info()` / `log.warn()` / log.error()` / log.fatal()` / log.debug()` in their scripts, e.g.: log.info( 'This is an info message' ); log.warn( 'Warning!' ); The custom log message will sequentially appear alongside internal mongosh messages, and will look similar to this: { "t" :{ "$date" : "2025-01-06T16:14:23.023Z" }, "s" : "I" , "c" : "MONGOSH" , "id" :1000000012, "ctx" : "shell-api" , "msg" : "Loading file via load()" , "attr" :{ "nested" : false , "filename" : "/Users/alena.khineika/custom-logging.js" }}{ "t" :{ "$date" : "2025-01-06T16:14:23.041Z" }, "s" : "I" , "c" : "MONGOSH-SCRIPTS" , "id" :1000000054, "ctx" : "custom-log" , "msg" : "This is an info message" }{ "t" :{ "$date" : "2025-01-06T16:14:23.041Z" }, "s" : "W" , "c" : "MONGOSH-SCRIPTS" , "id" :1000000054, "ctx" : "custom-log" , "msg" : "Warning!" }
    • Developer Tools

      Allow users to add custom entries to mongosh logs in their scripts.

            Assignee:
            alena.khineika@mongodb.com Alena Khineika
            Reporter:
            alena.khineika@mongodb.com Alena Khineika
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: