-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrace_impl.h
83 lines (73 loc) · 3.13 KB
/
trace_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_
#include "rtc_base/trace.h"
// Based on webrtc/system_wrappers/source/trace_impl.h in owt-deps-webrtc-59-server
// 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_MESSAGE_SIZE (number of 1 byte characters per line) =
// 1 or 4 Mbyte.
#define WEBRTC_TRACE_MAX_MESSAGE_SIZE 1024
// 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 =
// 25.6 Mbyte
#define WEBRTC_TRACE_MAX_FILE_SIZE 1000 // 100*1000
// Max length of file_name_utf8
#define WEBRTC_TRACE_MAX_FILENAME_SIZE 256
// Number of ostream that my be added
#define WEBRTC_TRACE_MAX_OSTREAM_NUMBER 3
#if defined(__cplusplus)
extern "C" { // namespace webrtc {
#endif
// The length of the trace text preceeding the log message.
static const int kBoilerplateLength = 71; // 12(level)+22(time)+25(module,id)+12(tid)
// The length of the timestamp (without "delta" field).
// static const int kTimestampLength = 12;
// The position of the timestamp text within a trace.
// static const int kTimestampPosition = 13; // kTimestampLength+1
// static volatile int level_filter_ = kTraceDefault;
typedef struct {
TraceOStream ostream;
long wrap_offset;
size_t row_count_text;
// size_t file_count_text;
} TraceHandle;
// Form trace message
static void AddImpl(const TraceLevel level,
const TraceModule module,
const int id,
const char* msg);
static int AddLevel(char* trace_message,
const TraceLevel level);
static int AddModuleAndId(char* trace_message,
const TraceModule module,
const int id);
static int AddTraceMessage(char* trace_message,
const char* msg,
const int written_so_far);
static void AddTraceMessageToList(const char* trace_message,
const int length,
const TraceLevel level);
// OS specific implementations.
static int AddTime(char* trace_message,
const TraceLevel level);
static int AddDateTimeInfo(char* trace_message);
static int AddThreadId(char* trace_message);
// Handle functions
static void WriteToFile(TraceHandle *handle,
const char* msg,
int length);
static bool CheckLevel(TraceHandle *handle,
const TraceLevel level);
#if defined(__cplusplus)
} // } // namespace webrtc
#endif
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_IMPL_H_