<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Am 22.01.21 um 22:10 schrieb Ben
      Bucksch:<br>
    </div>
    <blockquote type="cite"
      cite="mid:dfb6f973-4782-54f4-f8b1-b63e16b72f9b@beonex.com">
      <div class="moz-cite-prefix">Am 19.01.21 um 02:12 schrieb Ping
        Chen:<br>
      </div>
      <blockquote type="cite"
        cite="mid:28cfb5cf-36f0-4003-4ca9-57f47ff83e23@gmail.com">
        <blockquote type="cite">    // Create a ConsoleInstance from a
          ConsoleInstanceOptions object. <br>
              let logger = console.createInstance({ <br>
                prefix: "mailnews.smtp", <br>
                maxLogLevel: "Warn", <br>
                maxLogLevelPref: "mailnews.smtp.loglevel", <br>
              }); <br>
          <br>
              // Logging. <br>
              logger.log("Won't show up because Log level is less than
          Warn") <br>
              logger.warn("A warning") <br>
              logger.error("An error") <br>
        </blockquote>
      </blockquote>
      <p><br>
      </p>
      <p>I think this is a nice change, compared to the multitude of
        other inconsistent solutions that we have.</p>
      <p>But one remark to make it even better:<br>
      </p>
      <blockquote type="cite"
        cite="mid:28cfb5cf-36f0-4003-4ca9-57f47ff83e23@gmail.com">
        <blockquote type="cite"> </blockquote>
        For logging purpose yes. We don't need to print debugging logs
        to normal users. But still when needed, by toggling a pref, the
        logs can be shown. <br>
        <br>
        I think raw console.log should generally not be committed. <br>
      </blockquote>
      <p><br>
      </p>
      <p>If we're completely banning <code>console.log()</code>, then
        how about this:</p>
      <p>When initing the module, instead of saving <code>logger</code>
        in a variable and using that everywhere, what about allowing
        code to continue to use the standard <code>console.log(str)</code>,
        <code>console.error(ex)</code>, <code>console.warn(str)</code>
        etc., and redirecting those to the logger? That could be as
        simple as overwriting the <code>console</code> object with <code>logger</code>.</p>
      <p>Advantages:</p>
      <ul>
        <li>Using standardized functions (which work in browsers,
          node.js, and XPCOM JS code), and just making them do what we
          need</li>
        <li>Avoid review roundtrips for patches from contributors</li>
        <li>Avoid changing the entire code code base.</li>
        <li>Avoid having to find a suitable place to store the variable.
          (<code>this._logger</code>? <code>logger</code>? <code>gLogger</code>?
          etc.).</li>
      </ul>
      <p>Ben<br>
      </p>
    </blockquote>
    <p><br>
    </p>
    <p>To clarify:</p>
    <p><br>
          console = console.createInstance({ <br>
            prefix: "mailnews.smtp", <br>
            maxLogLevel: "Warn", <br>
            maxLogLevelPref: "mailnews.smtp.loglevel", <br>
          }); <br>
      <br>
          // Logging. <br>
          console.log("Won't show up because Log level is less than
      Warn") <br>
          console.warn("A warning") <br>
          console.error("An error") </p>
    <p>--> all those would go to the logging module, which then
      decides whether to print it to error console, stdout, log, or
      ignore it, depending on preferences.</p>
    <p><br>
    </p>
  </body>
</html>