Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
e562e001
Commit
e562e001
authored
Sep 02, 2016
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed force_flush arg from API (use flush_on(level) instead)
parent
1df30a07
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
22 deletions
+21
-22
example.cpp
example/example.cpp
+3
-4
spdlog_impl.h
include/spdlog/details/spdlog_impl.h
+12
-12
spdlog.h
include/spdlog/spdlog.h
+6
-6
No files found.
example/example.cpp
View file @
e562e001
...
...
@@ -56,6 +56,8 @@ int main(int, char*[])
// Create a daily logger - a new file is created every day on 2:30am
auto
daily_logger
=
spd
::
daily_logger_mt
(
"daily_logger"
,
"logs/daily"
,
2
,
30
);
// trigger flush if the log severity is error or higher
daily_logger
->
flush_on
(
spd
::
level
::
err
);
daily_logger
->
info
(
123.44
);
// Customize msg format for all messages
...
...
@@ -102,10 +104,7 @@ void async_example()
size_t
q_size
=
4096
;
//queue size must be power of 2
spdlog
::
set_async_mode
(
q_size
);
auto
async_file
=
spd
::
daily_logger_st
(
"async_file_logger"
,
"logs/async_log.txt"
);
// auto flush if the log severity is error or higher
async_file
->
flush_on
(
spd
::
level
::
err
);
for
(
int
i
=
0
;
i
<
100
;
++
i
)
async_file
->
info
(
"Async message #{}"
,
i
);
}
...
...
include/spdlog/details/spdlog_impl.h
View file @
e562e001
...
...
@@ -36,36 +36,36 @@ inline void spdlog::drop(const std::string &name)
}
// Create multi/single threaded simple file logger
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
basic_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
force_flush
,
bool
truncate
)
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
basic_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
)
{
return
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
logger_name
,
filename
,
force_flush
,
truncate
);
return
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
logger_name
,
filename
,
truncate
);
}
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
basic_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
force_flush
,
bool
truncate
)
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
basic_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
)
{
return
create
<
spdlog
::
sinks
::
simple_file_sink_st
>
(
logger_name
,
filename
,
force_flush
,
truncate
);
return
create
<
spdlog
::
sinks
::
simple_file_sink_st
>
(
logger_name
,
filename
,
truncate
);
}
// Create multi/single threaded rotating file logger
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
rotating_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
force_flush
)
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
rotating_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
)
{
return
create
<
spdlog
::
sinks
::
rotating_file_sink_mt
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
max_file_size
,
max_files
,
force_flush
);
return
create
<
spdlog
::
sinks
::
rotating_file_sink_mt
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
max_file_size
,
max_files
);
}
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
rotating_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
force_flush
)
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
rotating_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
)
{
return
create
<
spdlog
::
sinks
::
rotating_file_sink_st
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
max_file_size
,
max_files
,
force_flush
);
return
create
<
spdlog
::
sinks
::
rotating_file_sink_st
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
max_file_size
,
max_files
);
}
// Create file logger which creates new file at midnight):
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
daily_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
,
int
minute
,
bool
force_flush
)
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
daily_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
,
int
minute
)
{
return
create
<
spdlog
::
sinks
::
daily_file_sink_mt
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
hour
,
minute
,
force_flush
);
return
create
<
spdlog
::
sinks
::
daily_file_sink_mt
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
hour
,
minute
);
}
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
daily_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
,
int
minute
,
bool
force_flush
)
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
daily_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
,
int
minute
)
{
return
create
<
spdlog
::
sinks
::
daily_file_sink_st
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
hour
,
minute
,
force_flush
);
return
create
<
spdlog
::
sinks
::
daily_file_sink_st
>
(
logger_name
,
filename
,
SPDLOG_FILENAME_T
(
"txt"
),
hour
,
minute
);
}
// Create stdout/stderr loggers (with optinal color support)
...
...
include/spdlog/spdlog.h
View file @
e562e001
...
...
@@ -71,20 +71,20 @@ void set_sync_mode();
//
// Create and register multi/single basic file logger
//
std
::
shared_ptr
<
logger
>
basic_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
force_flush
=
false
,
bool
truncate
=
false
);
std
::
shared_ptr
<
logger
>
basic_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
force_flush
=
false
,
bool
truncate
=
false
);
std
::
shared_ptr
<
logger
>
basic_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
);
std
::
shared_ptr
<
logger
>
basic_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
);
//
// Create and register multi/single threaded rotating file logger
//
std
::
shared_ptr
<
logger
>
rotating_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
force_flush
=
false
);
std
::
shared_ptr
<
logger
>
rotating_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
force_flush
=
false
);
std
::
shared_ptr
<
logger
>
rotating_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
);
std
::
shared_ptr
<
logger
>
rotating_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
);
//
// Create file logger which creates new file on the given time (default in midnight):
//
std
::
shared_ptr
<
logger
>
daily_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
force_flush
=
false
);
std
::
shared_ptr
<
logger
>
daily_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
force_flush
=
false
);
std
::
shared_ptr
<
logger
>
daily_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
);
std
::
shared_ptr
<
logger
>
daily_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
);
//
// Create and register stdout/stderr loggers
...
...
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