tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

LoggingCore.h (1538B)


      1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 // Shared logging infrastructure across different binaries.
      7 
      8 #ifndef _mozilla_LoggingCore_h
      9 #define _mozilla_LoggingCore_h
     10 
     11 #include "mozilla/Atomics.h"
     12 #include "mozilla/Types.h"
     13 
     14 namespace mozilla {
     15 // While not a 100% mapping to PR_LOG's numeric values, mozilla::LogLevel does
     16 // maintain a direct mapping for the Disabled, Debug and Verbose levels.
     17 //
     18 // Mappings of LogLevel to PR_LOG's numeric values:
     19 //
     20 //   +---------+------------------+-----------------+
     21 //   | Numeric | NSPR Logging     | Mozilla Logging |
     22 //   +---------+------------------+-----------------+
     23 //   |       0 | PR_LOG_NONE      | Disabled        |
     24 //   |       1 | PR_LOG_ALWAYS    | Error           |
     25 //   |       2 | PR_LOG_ERROR     | Warning         |
     26 //   |       3 | PR_LOG_WARNING   | Info            |
     27 //   |       4 | PR_LOG_DEBUG     | Debug           |
     28 //   |       5 | PR_LOG_DEBUG + 1 | Verbose         |
     29 //   +---------+------------------+-----------------+
     30 //
     31 enum class LogLevel {
     32  Disabled = 0,
     33  Error,
     34  Warning,
     35  Info,
     36  Debug,
     37  Verbose,
     38 };
     39 
     40 /**
     41 * Safely converts an integer into a valid LogLevel.
     42 */
     43 MFBT_API LogLevel ToLogLevel(int32_t aLevel);
     44 
     45 using AtomicLogLevel = Atomic<LogLevel, Relaxed>;
     46 
     47 }  // namespace mozilla
     48 
     49 #endif /* _mozilla_LoggingCore_h */