Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-43652

Eventing app logs should treat tabs and newlines like node does

    XMLWordPrintable

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • CheshireCat.Next
    • Neo.next
    • eventing
    • None
    • 1

    Description

      In the UI and the file system application logs we should strive for parity with node.js as far as logging is concerned.

      When printing strings should expand \t and \n into an tab and a newline while when printing objects no expansion should be done.

      Consider the Eventing function (send it one mutation)

      function OnUpdate(doc, meta) {
          var d = Date.now();
       
          // tabs
          log(d + " [INFO] ", "a\tb");
          log(d + " [INFO] ", "a\t\t\t\tb");
       
          // new lines
          log(d + " [INFO] ", "a\n");
          log(d + " [INFO] ", "a\n\n\n\n");
       
          // objects
          log(d + " [INFO] ", { "a": "a\tb" });
          log(d + " [INFO] ", { "a": "a\t\t\t\tb" });
          log(d + " [INFO] ", { "a": "a\nb" });
          log(d + " [INFO] ", { "a": "a\n\n\n\nb" });
      }
      

      It has the following output

      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\tb" 
      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\t\t\t\tb" 
      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\n" 
      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\n\n\n\n" 
      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\tb"} 
      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\t\t\t\tb"} 
      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\nb"} 
      2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\n\n\n\nb"} 
      

      Now consider the equivalent node script

      var d = Date.now();
       
      // tabs
      console.log(d+" [INFO] ","a\tb");
      console.log(d+" [INFO] ","a\t\t\t\tb");
       
      // new lines
      console.log(d+" [INFO] ","a\n");
      console.log(d+" [INFO] ","a\n\n\n\n");
       
      // objects
      console.log(d+" [INFO] ",{"a": "a\tb"});
      console.log(d+" [INFO] ",{"a": "a\t\t\t\tb"});
      console.log(d+" [INFO] ",{"a": "a\nb"});
      console.log(d+" [INFO] ",{"a": "a\n\n\n\nb"});
      

      it has an output where both tabs \t and newlines \n are expanded

       

      1610690651546 [INFO]  a	b
      1610690651546 [INFO]  a				b
      1610690651546 [INFO]  a
       
       
      1610690651546 [INFO]  a
       
       
       
       
       
       
       
       
      1610690651546 [INFO]  { a: 'a\tb' }
      1610690651546 [INFO]  { a: 'a\t\t\t\tb' }
      1610690651546 [INFO]  { a: 'a\nb' }
      1610690651546 [INFO]  { a: 'a\n\n\n\nb' }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          There are no comments yet on this issue.

          People

            srinivasan.raman Srinivasan Raman
            jon.strabala Jon Strabala
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty