Reformatted trace* files.
BUG= TEST=Trybots. Review URL: https://webrtc-codereview.appspot.com/1015004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3329 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
		@@ -6,71 +6,72 @@
 | 
				
			|||||||
 *  tree. An additional intellectual property rights grant can be found
 | 
					 *  tree. An additional intellectual property rights grant can be found
 | 
				
			||||||
 *  in the file PATENTS.  All contributing project authors may
 | 
					 *  in the file PATENTS.  All contributing project authors may
 | 
				
			||||||
 *  be found in the AUTHORS file in the root of the source tree.
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  System independent wrapper for logging runtime information to file.
 | 
				
			||||||
 | 
					 *  Note: All log messages will be written to the same trace file.
 | 
				
			||||||
 | 
					 *  Note: If too many messages are written to file there will be a build up of
 | 
				
			||||||
 | 
					 *  messages. Apply filtering to avoid that.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// System independent wrapper for logging runtime information to file.
 | 
					 | 
				
			||||||
// Note: All log messages will be written to the same trace file.
 | 
					 | 
				
			||||||
// Note: If too many messages are written to file there will be a build up of
 | 
					 | 
				
			||||||
//       messages. Apply filtering to avoid that.
 | 
					 | 
				
			||||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_
 | 
					#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_
 | 
				
			||||||
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_
 | 
					#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "common_types.h"
 | 
					#include "webrtc/common_types.h"
 | 
				
			||||||
#include "typedefs.h"
 | 
					#include "webrtc/typedefs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define WEBRTC_TRACE Trace::Add
 | 
					#define WEBRTC_TRACE Trace::Add
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace webrtc {
 | 
					namespace webrtc {
 | 
				
			||||||
class Trace
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Increments the reference count to the trace.
 | 
					class Trace {
 | 
				
			||||||
    static void CreateTrace();
 | 
					 public:
 | 
				
			||||||
    // Decrements the reference count to the trace.
 | 
					  // Increments the reference count to the trace.
 | 
				
			||||||
    static void ReturnTrace();
 | 
					  static void CreateTrace();
 | 
				
			||||||
    // Note: any instance that writes to the trace file should increment and
 | 
					  // Decrements the reference count to the trace.
 | 
				
			||||||
    // decrement the reference count on construction and destruction
 | 
					  static void ReturnTrace();
 | 
				
			||||||
    // respectively
 | 
					  // Note: any instance that writes to the trace file should increment and
 | 
				
			||||||
 | 
					  // decrement the reference count on construction and destruction,
 | 
				
			||||||
 | 
					  // respectively.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Specifies what type of messages should be written to the trace file. The
 | 
					  // Specifies what type of messages should be written to the trace file. The
 | 
				
			||||||
    // filter parameter is a bitmask where each message type is enumerated by
 | 
					  // filter parameter is a bitmask where each message type is enumerated by the
 | 
				
			||||||
    // the TraceLevel enumerator. TODO(hellner): why is the
 | 
					  // TraceLevel enumerator. TODO(hellner): why is the TraceLevel enumerator not
 | 
				
			||||||
    // TraceLevel enumerator not defined in this file?
 | 
					  // defined in this file?
 | 
				
			||||||
    static WebRtc_Word32 SetLevelFilter(const WebRtc_UWord32 filter);
 | 
					  static WebRtc_Word32 SetLevelFilter(const WebRtc_UWord32 filter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Returns what type of messages are written to the trace file.
 | 
					  // Returns what type of messages are written to the trace file.
 | 
				
			||||||
    static WebRtc_Word32 LevelFilter(WebRtc_UWord32& filter);
 | 
					  static WebRtc_Word32 LevelFilter(WebRtc_UWord32& filter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Sets the file name. If addFileCounter is false the same file will be
 | 
					  // Sets the file name. If add_file_counter is false the same file will be
 | 
				
			||||||
    // reused when it fills up. If it's true a new file with incremented name
 | 
					  // reused when it fills up. If it's true a new file with incremented name
 | 
				
			||||||
    // will be used.
 | 
					  // will be used.
 | 
				
			||||||
    static WebRtc_Word32 SetTraceFile(const char* fileName,
 | 
					  static WebRtc_Word32 SetTraceFile(const char* file_name,
 | 
				
			||||||
                                      const bool addFileCounter = false);
 | 
					                                    const bool add_file_counter = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Returns the name of the file that the trace is currently writing to.
 | 
					  // Returns the name of the file that the trace is currently writing to.
 | 
				
			||||||
    static WebRtc_Word32 TraceFile(char fileName[1024]);
 | 
					  static WebRtc_Word32 TraceFile(char file_name[1024]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Registers callback to receive trace messages. TODO (hellner)
 | 
					  // Registers callback to receive trace messages.
 | 
				
			||||||
    // why not use OutStream instead? Why is TraceCallback not defined in this
 | 
					  // TODO(hellner): Why not use OutStream instead? Why is TraceCallback not
 | 
				
			||||||
    // file
 | 
					  // defined in this file?
 | 
				
			||||||
    static WebRtc_Word32 SetTraceCallback(TraceCallback* callback);
 | 
					  static WebRtc_Word32 SetTraceCallback(TraceCallback* callback);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Adds a trace message for writing to file. The message is put in a queue
 | 
					  // Adds a trace message for writing to file. The message is put in a queue
 | 
				
			||||||
    // for writing to file whenever possible for performance reasons. I.e. there
 | 
					  // for writing to file whenever possible for performance reasons. I.e. there
 | 
				
			||||||
    // is a crash it is possible that the last, vital logs are not logged yet.
 | 
					  // is a crash it is possible that the last, vital logs are not logged yet.
 | 
				
			||||||
    // level is the type of message to log. If that type of messages is
 | 
					  // level is the type of message to log. If that type of messages is
 | 
				
			||||||
    // filtered it will not be written to file. module is an identifier for what
 | 
					  // filtered it will not be written to file. module is an identifier for what
 | 
				
			||||||
    // part of the code the message is coming.
 | 
					  // part of the code the message is coming.
 | 
				
			||||||
    // id is an identifier that should be unique for that set of classes that
 | 
					  // id is an identifier that should be unique for that set of classes that
 | 
				
			||||||
    // are associated (e.g. all instances owned by an engine).
 | 
					  // are associated (e.g. all instances owned by an engine).
 | 
				
			||||||
    // msg and the ellipsis are the same as e.g. sprintf.
 | 
					  // msg and the ellipsis are the same as e.g. sprintf.
 | 
				
			||||||
    // TODO (hellner) Why is TraceModule not defined in this file?
 | 
					  // TODO(hellner) Why is TraceModule not defined in this file?
 | 
				
			||||||
    static void Add(const TraceLevel level,
 | 
					  static void Add(const TraceLevel level,
 | 
				
			||||||
                    const TraceModule module,
 | 
					                  const TraceModule module,
 | 
				
			||||||
                    const WebRtc_Word32 id,
 | 
					                  const WebRtc_Word32 id,
 | 
				
			||||||
                    const char* msg, ...);
 | 
					                  const char* msg, ...);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace webrtc
 | 
					}  // namespace webrtc
 | 
				
			||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_
 | 
					
 | 
				
			||||||
 | 
					#endif  // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -11,122 +11,122 @@
 | 
				
			|||||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
 | 
					#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
 | 
				
			||||||
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
 | 
					#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "system_wrappers/interface/critical_section_wrapper.h"
 | 
					#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 | 
				
			||||||
#include "system_wrappers/interface/event_wrapper.h"
 | 
					#include "webrtc/system_wrappers/interface/event_wrapper.h"
 | 
				
			||||||
#include "system_wrappers/interface/file_wrapper.h"
 | 
					#include "webrtc/system_wrappers/interface/file_wrapper.h"
 | 
				
			||||||
#include "system_wrappers/interface/static_instance.h"
 | 
					#include "webrtc/system_wrappers/interface/static_instance.h"
 | 
				
			||||||
#include "system_wrappers/interface/trace.h"
 | 
					#include "webrtc/system_wrappers/interface/thread_wrapper.h"
 | 
				
			||||||
#include "system_wrappers/interface/thread_wrapper.h"
 | 
					#include "webrtc/system_wrappers/interface/trace.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace webrtc {
 | 
					namespace webrtc {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO (pwestin) WEBRTC_TRACE_MAX_QUEUE needs to be tweaked
 | 
					// TODO(pwestin) WEBRTC_TRACE_MAX_QUEUE needs to be tweaked
 | 
				
			||||||
// TODO (hellner) the buffer should be close to how much the system can write to
 | 
					// TODO(hellner) the buffer should be close to how much the system can write to
 | 
				
			||||||
//                file. Increasing the buffer will not solve anything. Sooner or
 | 
					//               file. Increasing the buffer will not solve anything. Sooner or
 | 
				
			||||||
//                later the buffer is going to fill up anyways.
 | 
					//               later the buffer is going to fill up anyways.
 | 
				
			||||||
#if defined(WEBRTC_IOS)
 | 
					#if defined(WEBRTC_IOS)
 | 
				
			||||||
    #define WEBRTC_TRACE_MAX_QUEUE  2000
 | 
					#define WEBRTC_TRACE_MAX_QUEUE  2000
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    #define WEBRTC_TRACE_MAX_QUEUE  8000
 | 
					#define WEBRTC_TRACE_MAX_QUEUE  8000
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#define WEBRTC_TRACE_NUM_ARRAY 2
 | 
					#define WEBRTC_TRACE_NUM_ARRAY 2
 | 
				
			||||||
#define WEBRTC_TRACE_MAX_MESSAGE_SIZE 256
 | 
					#define WEBRTC_TRACE_MAX_MESSAGE_SIZE 256
 | 
				
			||||||
// Total buffer size is WEBRTC_TRACE_NUM_ARRAY (number of buffer partitions) *
 | 
					// Total buffer size is WEBRTC_TRACE_NUM_ARRAY (number of buffer partitions) *
 | 
				
			||||||
// WEBRTC_TRACE_MAX_QUEUE (number of lines per buffer partition) *
 | 
					// WEBRTC_TRACE_MAX_QUEUE (number of lines per buffer partition) *
 | 
				
			||||||
// WEBRTC_TRACE_MAX_MESSAGE_SIZE (number of 1 byte charachters per line) =
 | 
					// WEBRTC_TRACE_MAX_MESSAGE_SIZE (number of 1 byte charachters per line) =
 | 
				
			||||||
// 1 or 4 Mbyte
 | 
					// 1 or 4 Mbyte.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define WEBRTC_TRACE_MAX_FILE_SIZE 100*1000
 | 
					#define WEBRTC_TRACE_MAX_FILE_SIZE 100*1000
 | 
				
			||||||
// Number of rows that may be written to file. On average 110 bytes per row (max
 | 
					// Number of rows that may be written to file. On average 110 bytes per row (max
 | 
				
			||||||
// 256 bytes per row). So on average 110*100*1000 = 11 Mbyte, max 256*100*1000 =
 | 
					// 256 bytes per row). So on average 110*100*1000 = 11 Mbyte, max 256*100*1000 =
 | 
				
			||||||
// 25.6 Mbyte
 | 
					// 25.6 Mbyte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TraceImpl : public Trace
 | 
					class TraceImpl : public Trace {
 | 
				
			||||||
{
 | 
					 public:
 | 
				
			||||||
public:
 | 
					  virtual ~TraceImpl();
 | 
				
			||||||
    virtual ~TraceImpl();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static TraceImpl* CreateInstance();
 | 
					  static TraceImpl* CreateInstance();
 | 
				
			||||||
    static TraceImpl* GetTrace(const TraceLevel level = kTraceAll);
 | 
					  static TraceImpl* GetTrace(const TraceLevel level = kTraceAll);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WebRtc_Word32 SetTraceFileImpl(const char* fileName,
 | 
					  WebRtc_Word32 SetTraceFileImpl(const char* file_name,
 | 
				
			||||||
                                   const bool addFileCounter);
 | 
					                                 const bool add_file_counter);
 | 
				
			||||||
    WebRtc_Word32 TraceFileImpl(
 | 
					  WebRtc_Word32 TraceFileImpl(
 | 
				
			||||||
        char fileName[FileWrapper::kMaxFileNameSize]);
 | 
					    char file_name[FileWrapper::kMaxFileNameSize]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WebRtc_Word32 SetTraceCallbackImpl(TraceCallback* callback);
 | 
					  WebRtc_Word32 SetTraceCallbackImpl(TraceCallback* callback);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void AddImpl(const TraceLevel level, const TraceModule module,
 | 
					  void AddImpl(const TraceLevel level, const TraceModule module,
 | 
				
			||||||
                 const WebRtc_Word32 id, const char* msg);
 | 
					               const WebRtc_Word32 id, const char* msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool StopThread();
 | 
					  bool StopThread();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool TraceCheck(const TraceLevel level) const;
 | 
					  bool TraceCheck(const TraceLevel level) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					 protected:
 | 
				
			||||||
    TraceImpl();
 | 
					  TraceImpl();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static TraceImpl* StaticInstance(CountOperation count_operation,
 | 
					  static TraceImpl* StaticInstance(CountOperation count_operation,
 | 
				
			||||||
        const TraceLevel level = kTraceAll);
 | 
					                                   const TraceLevel level = kTraceAll);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WebRtc_Word32 AddThreadId(char* traceMessage) const;
 | 
					  WebRtc_Word32 AddThreadId(char* trace_message) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // OS specific implementations
 | 
					  // OS specific implementations.
 | 
				
			||||||
    virtual WebRtc_Word32 AddTime(char* traceMessage,
 | 
					  virtual WebRtc_Word32 AddTime(char* trace_message,
 | 
				
			||||||
                                  const TraceLevel level) const = 0;
 | 
					                                const TraceLevel level) const = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual WebRtc_Word32 AddBuildInfo(char* traceMessage) const = 0;
 | 
					  virtual WebRtc_Word32 AddBuildInfo(char* trace_message) const = 0;
 | 
				
			||||||
    virtual WebRtc_Word32 AddDateTimeInfo(char* traceMessage) const = 0;
 | 
					  virtual WebRtc_Word32 AddDateTimeInfo(char* trace_message) const = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static bool Run(void* obj);
 | 
					  static bool Run(void* obj);
 | 
				
			||||||
    bool Process();
 | 
					  bool Process();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					 private:
 | 
				
			||||||
    friend class Trace;
 | 
					  friend class Trace;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WebRtc_Word32 AddLevel(char* szMessage, const TraceLevel level) const;
 | 
					  WebRtc_Word32 AddLevel(char* sz_message, const TraceLevel level) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WebRtc_Word32 AddModuleAndId(char* traceMessage, const TraceModule module,
 | 
					  WebRtc_Word32 AddModuleAndId(char* trace_message, const TraceModule module,
 | 
				
			||||||
                                 const WebRtc_Word32 id) const;
 | 
					                               const WebRtc_Word32 id) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WebRtc_Word32 AddMessage(char* traceMessage,
 | 
					  WebRtc_Word32 AddMessage(char* trace_message,
 | 
				
			||||||
                             const char msg[WEBRTC_TRACE_MAX_MESSAGE_SIZE],
 | 
					                           const char msg[WEBRTC_TRACE_MAX_MESSAGE_SIZE],
 | 
				
			||||||
                             const WebRtc_UWord16 writtenSoFar) const;
 | 
					                           const WebRtc_UWord16 written_so_far) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void AddMessageToList(
 | 
					  void AddMessageToList(
 | 
				
			||||||
        const char traceMessage[WEBRTC_TRACE_MAX_MESSAGE_SIZE],
 | 
					    const char trace_message[WEBRTC_TRACE_MAX_MESSAGE_SIZE],
 | 
				
			||||||
        const WebRtc_UWord16 length,
 | 
					    const WebRtc_UWord16 length,
 | 
				
			||||||
        const TraceLevel level);
 | 
					    const TraceLevel level);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool UpdateFileName(
 | 
					  bool UpdateFileName(
 | 
				
			||||||
        const char fileNameUTF8[FileWrapper::kMaxFileNameSize],
 | 
					    const char file_name_utf8[FileWrapper::kMaxFileNameSize],
 | 
				
			||||||
        char fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
 | 
					    char file_name_with_counter_utf8[FileWrapper::kMaxFileNameSize],
 | 
				
			||||||
        const WebRtc_UWord32 newCount) const;
 | 
					    const WebRtc_UWord32 new_count) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool CreateFileName(
 | 
					  bool CreateFileName(
 | 
				
			||||||
        const char fileNameUTF8[FileWrapper::kMaxFileNameSize],
 | 
					    const char file_name_utf8[FileWrapper::kMaxFileNameSize],
 | 
				
			||||||
        char fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
 | 
					    char file_name_with_counter_utf8[FileWrapper::kMaxFileNameSize],
 | 
				
			||||||
        const WebRtc_UWord32 newCount) const;
 | 
					    const WebRtc_UWord32 new_count) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void WriteToFile();
 | 
					  void WriteToFile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CriticalSectionWrapper* _critsectInterface;
 | 
					  CriticalSectionWrapper* critsect_interface_;
 | 
				
			||||||
    TraceCallback* _callback;
 | 
					  TraceCallback* callback_;
 | 
				
			||||||
    WebRtc_UWord32 _rowCountText;
 | 
					  WebRtc_UWord32 row_count_text_;
 | 
				
			||||||
    WebRtc_UWord32 _fileCountText;
 | 
					  WebRtc_UWord32 file_count_text_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    FileWrapper& _traceFile;
 | 
					  FileWrapper& trace_file_;
 | 
				
			||||||
    ThreadWrapper& _thread;
 | 
					  ThreadWrapper& thread_;
 | 
				
			||||||
    EventWrapper& _event;
 | 
					  EventWrapper& event_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // _critsectArray protects _activeQueue
 | 
					  // critsect_array_ protects active_queue_.
 | 
				
			||||||
    CriticalSectionWrapper* _critsectArray;
 | 
					  CriticalSectionWrapper* critsect_array_;
 | 
				
			||||||
    WebRtc_UWord16 _nextFreeIdx[WEBRTC_TRACE_NUM_ARRAY];
 | 
					  WebRtc_UWord16 next_free_idx_[WEBRTC_TRACE_NUM_ARRAY];
 | 
				
			||||||
    TraceLevel _level[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
 | 
					  TraceLevel level_[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
 | 
				
			||||||
    WebRtc_UWord16 _length[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
 | 
					  WebRtc_UWord16 length_[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
 | 
				
			||||||
    char* _messageQueue[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
 | 
					  char* message_queue_[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
 | 
				
			||||||
    WebRtc_UWord8 _activeQueue;
 | 
					  WebRtc_UWord8 active_queue_;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
} // namespace webrtc
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
 | 
					}  // namespace webrtc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,49 +8,39 @@
 | 
				
			|||||||
 *  be found in the AUTHORS file in the root of the source tree.
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "trace.h"
 | 
					#include "webrtc/system_wrappers/interface/trace.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace webrtc {
 | 
					namespace webrtc {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Trace::CreateTrace()
 | 
					void Trace::CreateTrace() {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Trace::ReturnTrace()
 | 
					void Trace::ReturnTrace() {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 Trace::SetLevelFilter(WebRtc_UWord32 /*filter*/)
 | 
					WebRtc_Word32 Trace::SetLevelFilter(WebRtc_UWord32 filter) {
 | 
				
			||||||
{
 | 
					  return 0;
 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 Trace::LevelFilter(WebRtc_UWord32& /*filter*/)
 | 
					WebRtc_Word32 Trace::LevelFilter(WebRtc_UWord32& filter) {
 | 
				
			||||||
{
 | 
					  return 0;
 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 Trace::TraceFile(
 | 
					WebRtc_Word32 Trace::TraceFile(char file_name[1024]) {
 | 
				
			||||||
    char/*fileName*/[1024])
 | 
					  return -1;
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 Trace::SetTraceFile(const char* /*fileName*/,
 | 
					WebRtc_Word32 Trace::SetTraceFile(const char* file_name,
 | 
				
			||||||
                                  const bool /*addFileCounter*/)
 | 
					                                  const bool add_file_counter) {
 | 
				
			||||||
{
 | 
					  return -1;
 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 Trace::SetTraceCallback(TraceCallback* /*callback*/)
 | 
					WebRtc_Word32 Trace::SetTraceCallback(TraceCallback* callback) {
 | 
				
			||||||
{
 | 
					  return -1;
 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Trace::Add(const TraceLevel /*level*/, const TraceModule /*module*/,
 | 
					void Trace::Add(const TraceLevel level, const TraceModule module,
 | 
				
			||||||
                const WebRtc_Word32 /*id*/, const char* /*msg*/, ...)
 | 
					                const WebRtc_Word32 id, const char* msg, ...) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace webrtc
 | 
					}  // namespace webrtc
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
 *  be found in the AUTHORS file in the root of the source tree.
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "trace_posix.h"
 | 
					#include "webrtc/system_wrappers/source/trace_posix.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <cassert>
 | 
					#include <cassert>
 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
@@ -17,19 +17,19 @@
 | 
				
			|||||||
#include <sys/time.h>
 | 
					#include <sys/time.h>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
#ifdef WEBRTC_ANDROID
 | 
					#ifdef WEBRTC_ANDROID
 | 
				
			||||||
    #include <pthread.h>
 | 
					#include <pthread.h>
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    #include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_DEBUG)
 | 
					#if defined(_DEBUG)
 | 
				
			||||||
    #define BUILDMODE "d"
 | 
					#define BUILDMODE "d"
 | 
				
			||||||
#elif defined(DEBUG)
 | 
					#elif defined(DEBUG)
 | 
				
			||||||
    #define BUILDMODE "d"
 | 
					#define BUILDMODE "d"
 | 
				
			||||||
#elif defined(NDEBUG)
 | 
					#elif defined(NDEBUG)
 | 
				
			||||||
    #define BUILDMODE "r"
 | 
					#define BUILDMODE "r"
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    #define BUILDMODE "?"
 | 
					#define BUILDMODE "?"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#define BUILDTIME __TIME__
 | 
					#define BUILDTIME __TIME__
 | 
				
			||||||
#define BUILDDATE __DATE__
 | 
					#define BUILDDATE __DATE__
 | 
				
			||||||
@@ -37,84 +37,75 @@
 | 
				
			|||||||
#define BUILDINFO BUILDDATE " " BUILDTIME " " BUILDMODE
 | 
					#define BUILDINFO BUILDDATE " " BUILDTIME " " BUILDMODE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace webrtc {
 | 
					namespace webrtc {
 | 
				
			||||||
TracePosix::TracePosix()
 | 
					
 | 
				
			||||||
{
 | 
					TracePosix::TracePosix() {
 | 
				
			||||||
    struct timeval systemTimeHighRes;
 | 
					  struct timeval system_time_high_res;
 | 
				
			||||||
    gettimeofday(&systemTimeHighRes, 0);
 | 
					  gettimeofday(&system_time_high_res, 0);
 | 
				
			||||||
    _prevAPITickCount = _prevTickCount = systemTimeHighRes.tv_sec;
 | 
					  prev_api_tick_count_ = prev_tick_count_ = system_time_high_res.tv_sec;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TracePosix::~TracePosix()
 | 
					TracePosix::~TracePosix() {
 | 
				
			||||||
{
 | 
					  StopThread();
 | 
				
			||||||
    StopThread();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 TracePosix::AddTime(char* traceMessage,
 | 
					WebRtc_Word32 TracePosix::AddTime(char* trace_message,
 | 
				
			||||||
                                  const TraceLevel level) const
 | 
					                                  const TraceLevel level) const {
 | 
				
			||||||
{
 | 
					  struct timeval system_time_high_res;
 | 
				
			||||||
    struct timeval systemTimeHighRes;
 | 
					  if (gettimeofday(&system_time_high_res, 0) == -1) {
 | 
				
			||||||
    if (gettimeofday(&systemTimeHighRes, 0) == -1)
 | 
					    return -1;
 | 
				
			||||||
    {
 | 
					  }
 | 
				
			||||||
        return -1;
 | 
					  struct tm buffer;
 | 
				
			||||||
    }
 | 
					  const struct tm* system_time =
 | 
				
			||||||
    struct tm buffer;
 | 
					    localtime_r(&system_time_high_res.tv_sec, &buffer);
 | 
				
			||||||
    const struct tm* systemTime =
 | 
					 | 
				
			||||||
        localtime_r(&systemTimeHighRes.tv_sec, &buffer);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const WebRtc_UWord32 ms_time = systemTimeHighRes.tv_usec / 1000;
 | 
					  const WebRtc_UWord32 ms_time = system_time_high_res.tv_usec / 1000;
 | 
				
			||||||
    WebRtc_UWord32 prevTickCount = 0;
 | 
					  WebRtc_UWord32 prev_tickCount = 0;
 | 
				
			||||||
    if (level == kTraceApiCall)
 | 
					  if (level == kTraceApiCall) {
 | 
				
			||||||
    {
 | 
					    prev_tickCount = prev_tick_count_;
 | 
				
			||||||
        prevTickCount = _prevTickCount;
 | 
					    prev_tick_count_ = ms_time;
 | 
				
			||||||
        _prevTickCount = ms_time;
 | 
					  } else {
 | 
				
			||||||
    } else {
 | 
					    prev_tickCount = prev_api_tick_count_;
 | 
				
			||||||
        prevTickCount = _prevAPITickCount;
 | 
					    prev_api_tick_count_ = ms_time;
 | 
				
			||||||
        _prevAPITickCount = ms_time;
 | 
					  }
 | 
				
			||||||
    }
 | 
					  WebRtc_UWord32 dw_delta_time = ms_time - prev_tickCount;
 | 
				
			||||||
    WebRtc_UWord32 dwDeltaTime = ms_time - prevTickCount;
 | 
					  if (prev_tickCount == 0) {
 | 
				
			||||||
    if (prevTickCount == 0)
 | 
					    dw_delta_time = 0;
 | 
				
			||||||
    {
 | 
					  }
 | 
				
			||||||
        dwDeltaTime = 0;
 | 
					  if (dw_delta_time > 0x0fffffff) {
 | 
				
			||||||
    }
 | 
					    // Either wraparound or data race.
 | 
				
			||||||
    if (dwDeltaTime > 0x0fffffff)
 | 
					    dw_delta_time = 0;
 | 
				
			||||||
    {
 | 
					  }
 | 
				
			||||||
        // Either wraparound or data race.
 | 
					  if (dw_delta_time > 99999) {
 | 
				
			||||||
        dwDeltaTime = 0;
 | 
					    dw_delta_time = 99999;
 | 
				
			||||||
    }
 | 
					  }
 | 
				
			||||||
    if(dwDeltaTime > 99999)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        dwDeltaTime = 99999;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sprintf(traceMessage, "(%2u:%2u:%2u:%3u |%5lu) ", systemTime->tm_hour,
 | 
					  sprintf(trace_message, "(%2u:%2u:%2u:%3u |%5lu) ", system_time->tm_hour,
 | 
				
			||||||
            systemTime->tm_min, systemTime->tm_sec, ms_time,
 | 
					          system_time->tm_min, system_time->tm_sec, ms_time,
 | 
				
			||||||
            static_cast<unsigned long>(dwDeltaTime));
 | 
					          static_cast<unsigned long>(dw_delta_time));
 | 
				
			||||||
    // Messages are 22 characters.
 | 
					  // Messages are 22 characters.
 | 
				
			||||||
    return 22;
 | 
					  return 22;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 TracePosix::AddBuildInfo(char* traceMessage) const
 | 
					WebRtc_Word32 TracePosix::AddBuildInfo(char* trace_message) const {
 | 
				
			||||||
{
 | 
					  sprintf(trace_message, "Build info: %s", BUILDINFO);
 | 
				
			||||||
    sprintf(traceMessage, "Build info: %s", BUILDINFO);
 | 
					  // Include NULL termination (hence + 1).
 | 
				
			||||||
    // Include NULL termination (hence + 1).
 | 
					  return strlen(trace_message) + 1;
 | 
				
			||||||
    return strlen(traceMessage) + 1;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 TracePosix::AddDateTimeInfo(char* traceMessage) const
 | 
					WebRtc_Word32 TracePosix::AddDateTimeInfo(char* trace_message) const {
 | 
				
			||||||
{
 | 
					  time_t t;
 | 
				
			||||||
    time_t t;
 | 
					  time(&t);
 | 
				
			||||||
    time(&t);
 | 
					  char buffer[26];  // man ctime says buffer should have room for >=26 bytes.
 | 
				
			||||||
    char buffer[26];  // man ctime says buffer should have room for >=26 bytes.
 | 
					  sprintf(trace_message, "Local Date: %s", ctime_r(&t, buffer));
 | 
				
			||||||
    sprintf(traceMessage, "Local Date: %s", ctime_r(&t, buffer));
 | 
					  WebRtc_Word32 len = static_cast<WebRtc_Word32>(strlen(trace_message));
 | 
				
			||||||
    WebRtc_Word32 len = static_cast<WebRtc_Word32>(strlen(traceMessage));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ('\n' == traceMessage[len - 1])
 | 
					  if ('\n' == trace_message[len - 1]) {
 | 
				
			||||||
    {
 | 
					    trace_message[len - 1] = '\0';
 | 
				
			||||||
        traceMessage[len - 1] = '\0';
 | 
					    --len;
 | 
				
			||||||
        --len;
 | 
					  }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Messages is 12 characters.
 | 
					  // Messages is 12 characters.
 | 
				
			||||||
    return len + 1;
 | 
					  return len + 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
} // namespace webrtc
 | 
					
 | 
				
			||||||
 | 
					}  // namespace webrtc
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,26 +11,27 @@
 | 
				
			|||||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
 | 
					#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
 | 
				
			||||||
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
 | 
					#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "critical_section_wrapper.h"
 | 
					#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 | 
				
			||||||
#include "trace_impl.h"
 | 
					#include "webrtc/system_wrappers/source/trace_impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace webrtc {
 | 
					namespace webrtc {
 | 
				
			||||||
class TracePosix : public TraceImpl
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    TracePosix();
 | 
					 | 
				
			||||||
    virtual ~TracePosix();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual WebRtc_Word32 AddTime(char* traceMessage,
 | 
					class TracePosix : public TraceImpl {
 | 
				
			||||||
                                  const TraceLevel level) const;
 | 
					 public:
 | 
				
			||||||
 | 
					  TracePosix();
 | 
				
			||||||
 | 
					  virtual ~TracePosix();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual WebRtc_Word32 AddBuildInfo(char* traceMessage) const;
 | 
					  virtual WebRtc_Word32 AddTime(char* trace_message,
 | 
				
			||||||
    virtual WebRtc_Word32 AddDateTimeInfo(char* traceMessage) const;
 | 
					                                const TraceLevel level) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					  virtual WebRtc_Word32 AddBuildInfo(char* trace_message) const;
 | 
				
			||||||
    volatile mutable WebRtc_UWord32  _prevAPITickCount;
 | 
					  virtual WebRtc_Word32 AddDateTimeInfo(char* trace_message) const;
 | 
				
			||||||
    volatile mutable WebRtc_UWord32  _prevTickCount;
 | 
					
 | 
				
			||||||
 | 
					 private:
 | 
				
			||||||
 | 
					  volatile mutable WebRtc_UWord32  prev_api_tick_count_;
 | 
				
			||||||
 | 
					  volatile mutable WebRtc_UWord32  prev_tick_count_;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
} // namespace webrtc
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
 | 
					}  // namespace webrtc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,11 +8,10 @@
 | 
				
			|||||||
 *  be found in the AUTHORS file in the root of the source tree.
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "system_wrappers/interface/trace.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "gtest/gtest.h"
 | 
					#include "gtest/gtest.h"
 | 
				
			||||||
#include "system_wrappers/source/cpu_measurement_harness.h"
 | 
					#include "webrtc/system_wrappers/interface/trace.h"
 | 
				
			||||||
#include "testsupport/fileutils.h"
 | 
					#include "webrtc/system_wrappers/source/cpu_measurement_harness.h"
 | 
				
			||||||
 | 
					#include "webrtc/test/testsupport/fileutils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using webrtc::CpuMeasurementHarness;
 | 
					using webrtc::CpuMeasurementHarness;
 | 
				
			||||||
using webrtc::Trace;
 | 
					using webrtc::Trace;
 | 
				
			||||||
@@ -23,8 +22,7 @@ class Logger : public webrtc::CpuTarget {
 | 
				
			|||||||
 public:
 | 
					 public:
 | 
				
			||||||
  Logger() {
 | 
					  Logger() {
 | 
				
			||||||
    Trace::CreateTrace();
 | 
					    Trace::CreateTrace();
 | 
				
			||||||
    std::string trace_file = webrtc::test::OutputPath() +
 | 
					    std::string trace_file = webrtc::test::OutputPath() + "trace_unittest.txt";
 | 
				
			||||||
        "trace_unittest.txt";
 | 
					 | 
				
			||||||
    Trace::SetTraceFile(trace_file.c_str());
 | 
					    Trace::SetTraceFile(trace_file.c_str());
 | 
				
			||||||
    Trace::SetLevelFilter(webrtc::kTraceAll);
 | 
					    Trace::SetLevelFilter(webrtc::kTraceAll);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -49,8 +47,8 @@ TEST(TraceTest, DISABLED_CpuUsage) {
 | 
				
			|||||||
  const int iterations_per_period = 10;
 | 
					  const int iterations_per_period = 10;
 | 
				
			||||||
  const int duration_ms = 1000;
 | 
					  const int duration_ms = 1000;
 | 
				
			||||||
  CpuMeasurementHarness* cpu_harness =
 | 
					  CpuMeasurementHarness* cpu_harness =
 | 
				
			||||||
      CpuMeasurementHarness::Create(&logger, periodicity_ms,
 | 
					    CpuMeasurementHarness::Create(&logger, periodicity_ms,
 | 
				
			||||||
                                    iterations_per_period, duration_ms);
 | 
					                                  iterations_per_period, duration_ms);
 | 
				
			||||||
  cpu_harness->Run();
 | 
					  cpu_harness->Run();
 | 
				
			||||||
  const int average_cpu = cpu_harness->AverageCpu();
 | 
					  const int average_cpu = cpu_harness->AverageCpu();
 | 
				
			||||||
  EXPECT_GE(5, average_cpu);
 | 
					  EXPECT_GE(5, average_cpu);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
 *  be found in the AUTHORS file in the root of the source tree.
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "trace_win.h"
 | 
					#include "webrtc/system_wrappers/source/trace_win.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <cassert>
 | 
					#include <cassert>
 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
@@ -16,13 +16,13 @@
 | 
				
			|||||||
#include "Mmsystem.h"
 | 
					#include "Mmsystem.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_DEBUG)
 | 
					#if defined(_DEBUG)
 | 
				
			||||||
    #define BUILDMODE "d"
 | 
					#define BUILDMODE "d"
 | 
				
			||||||
#elif defined(DEBUG)
 | 
					#elif defined(DEBUG)
 | 
				
			||||||
    #define BUILDMODE "d"
 | 
					#define BUILDMODE "d"
 | 
				
			||||||
#elif defined(NDEBUG)
 | 
					#elif defined(NDEBUG)
 | 
				
			||||||
    #define BUILDMODE "r"
 | 
					#define BUILDMODE "r"
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    #define BUILDMODE "?"
 | 
					#define BUILDMODE "?"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#define BUILDTIME __TIME__
 | 
					#define BUILDTIME __TIME__
 | 
				
			||||||
#define BUILDDATE __DATE__
 | 
					#define BUILDDATE __DATE__
 | 
				
			||||||
@@ -31,101 +31,89 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace webrtc {
 | 
					namespace webrtc {
 | 
				
			||||||
TraceWindows::TraceWindows()
 | 
					TraceWindows::TraceWindows()
 | 
				
			||||||
    : _prevAPITickCount(0),
 | 
					    : prev_api_tick_count_(0),
 | 
				
			||||||
      _prevTickCount(0)
 | 
					      prev_tick_count_(0) {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TraceWindows::~TraceWindows()
 | 
					TraceWindows::~TraceWindows() {
 | 
				
			||||||
{
 | 
					  StopThread();
 | 
				
			||||||
    StopThread();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 TraceWindows::AddTime(char* traceMessage,
 | 
					WebRtc_Word32 TraceWindows::AddTime(char* trace_message,
 | 
				
			||||||
                                    const TraceLevel level) const
 | 
					                                    const TraceLevel level) const {
 | 
				
			||||||
{
 | 
					  WebRtc_UWord32 dw_current_time = timeGetTime();
 | 
				
			||||||
    WebRtc_UWord32 dwCurrentTime = timeGetTime();
 | 
					  SYSTEMTIME system_time;
 | 
				
			||||||
    SYSTEMTIME systemTime;
 | 
					  GetSystemTime(&system_time);
 | 
				
			||||||
    GetSystemTime(&systemTime);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(level == kTraceApiCall)
 | 
					  if (level == kTraceApiCall) {
 | 
				
			||||||
    {
 | 
					    WebRtc_UWord32 dw_delta_time = dw_current_time - prev_tick_count_;
 | 
				
			||||||
        WebRtc_UWord32 dwDeltaTime = dwCurrentTime- _prevTickCount;
 | 
					    prev_tick_count_ = dw_current_time;
 | 
				
			||||||
        _prevTickCount = dwCurrentTime;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(_prevTickCount == 0)
 | 
					    if (prev_tick_count_ == 0) {
 | 
				
			||||||
        {
 | 
					      dw_delta_time = 0;
 | 
				
			||||||
            dwDeltaTime = 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if(dwDeltaTime > 0x0fffffff)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // Either wraparound or data race.
 | 
					 | 
				
			||||||
            dwDeltaTime = 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if(dwDeltaTime > 99999)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            dwDeltaTime = 99999;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        sprintf (traceMessage, "(%2u:%2u:%2u:%3u |%5lu) ", systemTime.wHour,
 | 
					 | 
				
			||||||
                 systemTime.wMinute, systemTime.wSecond,
 | 
					 | 
				
			||||||
                 systemTime.wMilliseconds, dwDeltaTime);
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        WebRtc_UWord32 dwDeltaTime = dwCurrentTime - _prevAPITickCount;
 | 
					 | 
				
			||||||
        _prevAPITickCount = dwCurrentTime;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(_prevAPITickCount == 0)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            dwDeltaTime = 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if(dwDeltaTime > 0x0fffffff)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // Either wraparound or data race.
 | 
					 | 
				
			||||||
            dwDeltaTime = 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if(dwDeltaTime > 99999)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            dwDeltaTime = 99999;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        sprintf (traceMessage, "(%2u:%2u:%2u:%3u |%5lu) ", systemTime.wHour,
 | 
					 | 
				
			||||||
                 systemTime.wMinute, systemTime.wSecond,
 | 
					 | 
				
			||||||
                 systemTime.wMilliseconds, dwDeltaTime);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Messages is 12 characters.
 | 
					    if (dw_delta_time > 0x0fffffff) {
 | 
				
			||||||
    return 22;
 | 
					      // Either wrap-around or data race.
 | 
				
			||||||
 | 
					      dw_delta_time = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (dw_delta_time > 99999) {
 | 
				
			||||||
 | 
					      dw_delta_time = 99999;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    sprintf(trace_message, "(%2u:%2u:%2u:%3u |%5lu) ", system_time.wHour,
 | 
				
			||||||
 | 
					            system_time.wMinute, system_time.wSecond,
 | 
				
			||||||
 | 
					            system_time.wMilliseconds, dw_delta_time);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    WebRtc_UWord32 dw_delta_time = dw_current_time - prev_api_tick_count_;
 | 
				
			||||||
 | 
					    prev_api_tick_count_ = dw_current_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (prev_api_tick_count_ == 0) {
 | 
				
			||||||
 | 
					      dw_delta_time = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (dw_delta_time > 0x0fffffff) {
 | 
				
			||||||
 | 
					      // Either wraparound or data race.
 | 
				
			||||||
 | 
					      dw_delta_time = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (dw_delta_time > 99999) {
 | 
				
			||||||
 | 
					      dw_delta_time = 99999;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    sprintf(trace_message, "(%2u:%2u:%2u:%3u |%5lu) ", system_time.wHour,
 | 
				
			||||||
 | 
					            system_time.wMinute, system_time.wSecond,
 | 
				
			||||||
 | 
					            system_time.wMilliseconds, dw_delta_time);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return 22;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 TraceWindows::AddBuildInfo(char* traceMessage) const
 | 
					WebRtc_Word32 TraceWindows::AddBuildInfo(char* trace_message) const {
 | 
				
			||||||
{
 | 
					  // write data and time to text file
 | 
				
			||||||
    // write data and time to text file
 | 
					  sprintf(trace_message, "Build info: %s", BUILDINFO);
 | 
				
			||||||
    sprintf(traceMessage, "Build info: %s", BUILDINFO);
 | 
					  // Include NULL termination (hence + 1).
 | 
				
			||||||
    // Include NULL termination (hence + 1).
 | 
					  return static_cast<WebRtc_Word32>(strlen(trace_message) + 1);
 | 
				
			||||||
    return static_cast<WebRtc_Word32>(strlen(traceMessage)+1);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebRtc_Word32 TraceWindows::AddDateTimeInfo(char* traceMessage) const
 | 
					WebRtc_Word32 TraceWindows::AddDateTimeInfo(char* trace_message) const {
 | 
				
			||||||
{
 | 
					  prev_api_tick_count_ = timeGetTime();
 | 
				
			||||||
    _prevAPITickCount = timeGetTime();
 | 
					  prev_tick_count_ = prev_api_tick_count_;
 | 
				
			||||||
    _prevTickCount = _prevAPITickCount;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SYSTEMTIME sysTime;
 | 
					  SYSTEMTIME sys_time;
 | 
				
			||||||
    GetLocalTime (&sysTime);
 | 
					  GetLocalTime(&sys_time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TCHAR szDateStr[20];
 | 
					  TCHAR sz_date_str[20];
 | 
				
			||||||
    TCHAR szTimeStr[20];
 | 
					  TCHAR sz_time_str[20];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Create date string (e.g. Apr 04 2002)
 | 
					  // Create date string (e.g. Apr 04 2002)
 | 
				
			||||||
    GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, TEXT("MMM dd yyyy"),
 | 
					  GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &sys_time, TEXT("MMM dd yyyy"),
 | 
				
			||||||
                  szDateStr, 20);
 | 
					                sz_date_str, 20);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Create time string (e.g. 15:32:08)
 | 
					  // Create time string (e.g. 15:32:08)
 | 
				
			||||||
    GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, TEXT("HH':'mm':'ss"),
 | 
					  GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &sys_time, TEXT("HH':'mm':'ss"),
 | 
				
			||||||
                  szTimeStr, 20);
 | 
					                sz_time_str, 20);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sprintf(traceMessage, "Local Date: %s Local Time: %s", szDateStr,
 | 
					  sprintf(trace_message, "Local Date: %s Local Time: %s", sz_date_str,
 | 
				
			||||||
            szTimeStr);
 | 
					          sz_time_str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Include NULL termination (hence + 1).
 | 
					  // Include NULL termination (hence + 1).
 | 
				
			||||||
    return static_cast<WebRtc_Word32>(strlen(traceMessage)+ 1);
 | 
					  return static_cast<WebRtc_Word32>(strlen(trace_message) + 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
} // namespace webrtc
 | 
					
 | 
				
			||||||
 | 
					}  // namespace webrtc
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,29 +8,31 @@
 | 
				
			|||||||
 *  be found in the AUTHORS file in the root of the source tree.
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WINDOWS_H_
 | 
					#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_
 | 
				
			||||||
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WINDOWS_H_
 | 
					#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "trace_impl.h"
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <windows.h>
 | 
					#include <windows.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "webrtc/system_wrappers/source/trace_impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace webrtc {
 | 
					namespace webrtc {
 | 
				
			||||||
class TraceWindows : public TraceImpl
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    TraceWindows();
 | 
					 | 
				
			||||||
    virtual ~TraceWindows();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual WebRtc_Word32 AddTime(char* traceMessage,
 | 
					class TraceWindows : public TraceImpl {
 | 
				
			||||||
                                  const TraceLevel level) const;
 | 
					 public:
 | 
				
			||||||
 | 
					  TraceWindows();
 | 
				
			||||||
 | 
					  virtual ~TraceWindows();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual WebRtc_Word32 AddBuildInfo(char* traceMessage) const;
 | 
					  virtual WebRtc_Word32 AddTime(char* trace_message,
 | 
				
			||||||
    virtual WebRtc_Word32 AddDateTimeInfo(char* traceMessage) const;
 | 
					                                const TraceLevel level) const;
 | 
				
			||||||
private:
 | 
					
 | 
				
			||||||
    volatile mutable WebRtc_UWord32    _prevAPITickCount;
 | 
					  virtual WebRtc_Word32 AddBuildInfo(char* trace_message) const;
 | 
				
			||||||
    volatile mutable WebRtc_UWord32   _prevTickCount;
 | 
					  virtual WebRtc_Word32 AddDateTimeInfo(char* trace_message) const;
 | 
				
			||||||
 | 
					 private:
 | 
				
			||||||
 | 
					  volatile mutable WebRtc_UWord32 prev_api_tick_count_;
 | 
				
			||||||
 | 
					  volatile mutable WebRtc_UWord32 prev_tick_count_;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
} // namespace webrtc
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WINDOWS_H_
 | 
					}  // namespace webrtc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user