Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HelloWorld
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZhongJianfu
HelloWorld
Commits
36107efe
Commit
36107efe
authored
Mar 25, 2022
by
ZhongJianfu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:日志超限备份
parent
49ac57da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
my_easylogging.cpp
feature/easylogging/my_easylogging.cpp
+10
-4
log.conf
log/log.conf
+1
-1
No files found.
feature/easylogging/my_easylogging.cpp
View file @
36107efe
#include "my_easylogging.h"
#include "my_easylogging.h"
//
#include <ctime>
#include <ctime>
using
namespace
std
;
using
namespace
std
;
INT32
G_LOG_ENABLE
=
0
;
//调试中的变量,写0就好了。写1则开启相应打印
INT32
G_LOG_ENABLE
=
0
;
//调试中的变量,写0就好了。写1则开启相应打印
...
@@ -46,7 +46,10 @@ void rolloutHandler(const char *filename, std::size_t size)
...
@@ -46,7 +46,10 @@ void rolloutHandler(const char *filename, std::size_t size)
{
{
/// 备份日志
/// 备份日志
static
unsigned
int
idx
;
static
unsigned
int
idx
;
time_t
nowtime
;
struct
tm
*
p
;
time
(
&
nowtime
);
p
=
localtime
(
&
nowtime
);
#if defined(_WIN32)
#if defined(_WIN32)
cout
<<
"###########LOG SIZE FULL#############"
<<
endl
;
cout
<<
"###########LOG SIZE FULL#############"
<<
endl
;
std
::
stringstream
ss
;
std
::
stringstream
ss
;
...
@@ -56,11 +59,14 @@ void rolloutHandler(const char *filename, std::size_t size)
...
@@ -56,11 +59,14 @@ void rolloutHandler(const char *filename, std::size_t size)
replace
(
cc
.
begin
(),
cc
.
end
(),
'/'
,
'\\'
);
replace
(
cc
.
begin
(),
cc
.
end
(),
'/'
,
'\\'
);
system
(
cc
.
c_str
());
system
(
cc
.
c_str
());
#else
#else
/*下面这段
没有测试过
需要优化*/
/*下面这段 需要优化*/
// system("mkdir bin");
// system("mkdir bin");
std
::
stringstream
ss
;
std
::
stringstream
ss
;
std
::
time_t
t
=
std
::
time
(
0
);
// t is an integer type
ss
<<
"mv "
ss
<<
"mv "
<<
filename
<<
" ./log/log_backup_"
<<
++
idx
;
<<
filename
<<
" ./log/log_backup_"
<<
++
idx
<<
"_"
<<
p
->
tm_year
<<
p
->
tm_mon
<<
p
->
tm_mday
<<
".log"
;
system
(
ss
.
str
().
c_str
());
system
(
ss
.
str
().
c_str
());
#endif
#endif
}
}
...
...
log/log.conf
View file @
36107efe
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
TO_FILE
=
true
TO_FILE
=
true
TO_STANDARD_OUTPUT
=
false
TO_STANDARD_OUTPUT
=
false
PERFORMANCE_TRACKING
=
false
PERFORMANCE_TRACKING
=
false
MAX_LOG_FILE_SIZE
=
1
MAX_LOG_FILE_SIZE
=
209715200
FILENAME
=
"./log/info_%datetime{%Y%M%d}.log"
FILENAME
=
"./log/info_%datetime{%Y%M%d}.log"
*
INFO
:
*
INFO
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment