LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/system_wrappers/include - trace.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 8 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  *
      10             :  *  System independent wrapper for logging runtime information to file.
      11             :  *  Note: All log messages will be written to the same trace file.
      12             :  *  Note: If too many messages are written to file there will be a build up of
      13             :  *  messages. Apply filtering to avoid that.
      14             :  */
      15             : 
      16             : #ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TRACE_H_
      17             : #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TRACE_H_
      18             : 
      19             : #include "webrtc/common_types.h"
      20             : #include "webrtc/typedefs.h"
      21             : #include <string>
      22             : 
      23             : namespace webrtc {
      24             : 
      25             : #if defined(WEBRTC_RESTRICT_LOGGING)
      26             : // Disable all TRACE macros. The LOG macro is still functional.
      27             : #define WEBRTC_TRACE true ? (void) 0 : Trace::Add
      28             : #else
      29             : #define WEBRTC_TRACE Trace::Add
      30             : #endif
      31             : 
      32           0 : class Trace {
      33             :  public:
      34             :   // The length of the trace text preceeding the log message.
      35             :   static const int kBoilerplateLength;
      36             :   // The position of the timestamp text within a trace.
      37             :   static const int kTimestampPosition;
      38             :   // The length of the timestamp (without "delta" field).
      39             :   static const int kTimestampLength;
      40             : 
      41             :   // Increments the reference count to the trace.
      42             :   static void CreateTrace();
      43             :   // Decrements the reference count to the trace.
      44             :   static void ReturnTrace();
      45             :   // Note: any instance that writes to the trace file should increment and
      46             :   // decrement the reference count on construction and destruction,
      47             :   // respectively.
      48             : 
      49             :   // Specifies what type of messages should be written to the trace file. The
      50             :   // filter parameter is a bitmask where each message type is enumerated by the
      51             :   // TraceLevel enumerator. TODO(hellner): why is the TraceLevel enumerator not
      52             :   // defined in this file?
      53             :   static void set_level_filter(int filter);
      54             : 
      55             :   // Returns what type of messages are written to the trace file.
      56             :   static int level_filter();
      57             : 
      58             :   // Enable dumping of AEC inputs and outputs.  Can be changed in mid-call
      59           0 :   static void set_aec_debug(bool enable) { aec_debug_ = enable; }
      60           0 :   static void set_aec_debug_size(uint32_t size) { aec_debug_size_ = size; }
      61           0 :   static bool aec_debug() { return aec_debug_; }
      62           0 :   static uint32_t aec_debug_size() { return aec_debug_size_; }
      63             :   static void aec_debug_filename(char *buffer, size_t size);
      64           0 :   static void set_aec_debug_filename(const char* filename) {
      65           0 :     aec_filename_base_ = filename;
      66           0 :   }
      67             : 
      68             :   // Sets the file name. If add_file_counter is false the same file will be
      69             :   // reused when it fills up. If it's true a new file with incremented name
      70             :   // will be used.
      71             :   static int32_t SetTraceFile(const char* file_name,
      72             :                               const bool add_file_counter = false);
      73             : 
      74             :   // Registers callback to receive trace messages.
      75             :   // TODO(hellner): Why not use OutStream instead? Why is TraceCallback not
      76             :   // defined in this file?
      77             :   static int32_t SetTraceCallback(TraceCallback* callback);
      78             : 
      79             :   // Adds a trace message for writing to file. The message is put in a queue
      80             :   // for writing to file whenever possible for performance reasons. I.e. there
      81             :   // is a crash it is possible that the last, vital logs are not logged yet.
      82             :   // level is the type of message to log. If that type of messages is
      83             :   // filtered it will not be written to file. module is an identifier for what
      84             :   // part of the code the message is coming.
      85             :   // id is an identifier that should be unique for that set of classes that
      86             :   // are associated (e.g. all instances owned by an engine).
      87             :   // msg and the ellipsis are the same as e.g. sprintf.
      88             :   // TODO(hellner) Why is TraceModule not defined in this file?
      89             :   static void Add(const TraceLevel level,
      90             :                   const TraceModule module,
      91             :                   const int32_t id,
      92             :                   const char* msg, ...);
      93             : 
      94             :  private:
      95             :   static volatile int level_filter_;
      96             :   static bool aec_debug_;
      97             :   static uint32_t aec_debug_size_;
      98             :   static std::string aec_filename_base_;
      99             : };
     100             : 
     101             : extern "C" {
     102             :   extern int AECDebug();
     103             :   extern uint32_t AECDebugMaxSize();
     104             :   extern void AECDebugEnable(uint32_t enable);
     105             :   extern void AECDebugFilenameBase(char *buffer, size_t size);
     106             : }
     107             : 
     108             : }  // namespace webrtc
     109             : 
     110             : #endif  // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TRACE_H_

Generated by: LCOV version 1.13