-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path_test_log.cpp
More file actions
132 lines (117 loc) · 2.49 KB
/
_test_log.cpp
File metadata and controls
132 lines (117 loc) · 2.49 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
* @file tests for log.h/cpp
* @brief
* @ref
* @author Yonhgwhan, Roh (fixbrain@gmail.com)
* @date 2018/12/08 created.
* @copyright All rights reserved by Yonghwan, Roh.
**/
#include "stdafx.h"
#include "_MyLib/src/log.h"
bool test_log_rotate_with_no_file();
bool test_log_rotate_with_ext();
bool test_log_rotate_without_ext();
bool test_log_rotate()
{
if (true != test_log_rotate_with_no_file()) return false;
if (true != test_log_rotate_with_ext()) return false;
if (true != test_log_rotate_without_ext()) return false;
return true;
}
bool test_log_rotate_with_no_file()
{
//
// init file log
//
uint32_t log_id = GetCurrentProcessId();
_ASSERTE(true == initialize_log(log_id,
log_mask_all,
log_level_debug,
log_to_con | log_to_ods,
nullptr));
//
// log, log, log...
//
for (int i = 0; i < (5 * 5 + 1); ++i)
{
Sleep(300);
log_info "log rotate test... %d", i log_end;
}
//
// finalize file log
//
log_info "end log rotate test" log_end;
finalize_log(log_id);
return true;
}
bool test_log_rotate_with_ext()
{
uint32_t log_id = GetCurrentProcessId();
//
// init file log
//
std::wstringstream log_file_path;
log_file_path
<< get_current_module_dirEx()
<< L"\\test_log_rotate.log";
_ASSERTE(true == initialize_log(log_id,
log_mask_all,
log_level_debug,
log_to_all,
log_file_path.str().c_str(),
5, // 로그 파일당 로그 5줄
5 // 로그 파일의 최대 갯수는 5개
));
//
// rotate log file few times for test
//
for (int i = 0; i < (5 * 5 + 1); ++i)
{
Sleep(300);
log_info "log rotate test... %d", i log_end;
}
//
//
//
//
// finalize file log
//
log_info "end log rotate test" log_end;
finalize_log(log_id);
return true;
}
bool test_log_rotate_without_ext()
{
//
// init file log
//
std::wstringstream log_file_path;
log_file_path
<< get_current_module_dirEx()
<< L"\\test_log_rotate_no_ext";
_ASSERTE(true == initialize_log(GetCurrentProcessId(),
log_mask_all,
log_level_debug,
log_to_all,
log_file_path.str().c_str(),
5, // 로그 파일당 로그 5줄
5 // 로그 파일의 최대 갯수는 5개
));
//
// rotate log file few times for test
//
for (int i = 0; i < (5 * 5 + 1); ++i)
{
Sleep(300);
log_info "log rotate test... %d", i log_end;
}
//
//
//
//
// finalize file log
//
log_info "end log rotate test" log_end;
finalize_log(GetCurrentProcessId());
return true;
}