Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
5b7dfefc
Commit
5b7dfefc
authored
Nov 16, 2021
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename file_event_handlers_t to file_event_handlers
parent
e86be93b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
25 additions
and
25 deletions
+25
-25
README.md
README.md
+2
-2
example/example.cpp
example/example.cpp
+2
-2
include/spdlog/common.h
include/spdlog/common.h
+2
-2
include/spdlog/details/file_helper-inl.h
include/spdlog/details/file_helper-inl.h
+1
-1
include/spdlog/details/file_helper.h
include/spdlog/details/file_helper.h
+2
-2
include/spdlog/sinks/basic_file_sink-inl.h
include/spdlog/sinks/basic_file_sink-inl.h
+1
-1
include/spdlog/sinks/basic_file_sink.h
include/spdlog/sinks/basic_file_sink.h
+3
-3
include/spdlog/sinks/daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+5
-5
include/spdlog/sinks/hourly_file_sink.h
include/spdlog/sinks/hourly_file_sink.h
+3
-3
include/spdlog/sinks/rotating_file_sink-inl.h
include/spdlog/sinks/rotating_file_sink-inl.h
+1
-1
include/spdlog/sinks/rotating_file_sink.h
include/spdlog/sinks/rotating_file_sink.h
+3
-3
No files found.
README.md
View file @
5b7dfefc
...
...
@@ -381,8 +381,8 @@ $ ./example
// This is useful for cleanup procedures or for adding someting the start/end of the log files.
void
file_events_example
()
{
// pass the spdlog::file_event_handlers
_t
to file sinks for open/close log file notifications
spdlog
::
file_event_handlers
_t
handlers
;
// pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
spdlog
::
file_event_handlers
handlers
;
handlers
.
before_open
=
[](
spdlog
::
filename_t
filename
)
{
spdlog
::
info
(
"Before opening {}"
,
filename
);
};
handlers
.
after_open
=
[](
spdlog
::
filename_t
filename
,
std
::
FILE
*
fstream
)
{
fputs
(
"After opening
\n
"
,
fstream
);
};
handlers
.
before_close
=
[](
spdlog
::
filename_t
filename
,
std
::
FILE
*
fstream
)
{
fputs
(
"Before closing
\n
"
,
fstream
);
};
...
...
example/example.cpp
View file @
5b7dfefc
...
...
@@ -310,8 +310,8 @@ void custom_flags_example()
void
file_events_example
()
{
// pass the spdlog::file_event_handlers
_t
to file sinks for open/close log file notifications
spdlog
::
file_event_handlers
_t
handlers
;
// pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
spdlog
::
file_event_handlers
handlers
;
handlers
.
before_open
=
[](
spdlog
::
filename_t
filename
)
{
spdlog
::
info
(
"Before opening {}"
,
filename
);
};
handlers
.
after_open
=
[](
spdlog
::
filename_t
filename
,
std
::
FILE
*
fstream
)
{
spdlog
::
info
(
"After opening {}"
,
filename
);
...
...
include/spdlog/common.h
View file @
5b7dfefc
...
...
@@ -256,7 +256,7 @@ struct source_loc
const
char
*
funcname
{
nullptr
};
};
typedef
struct
file_event_handlers
struct
file_event_handlers
{
std
::
function
<
void
(
const
filename_t
&
filename
)
>
before_open
;
std
::
function
<
void
(
const
filename_t
&
filename
,
std
::
FILE
*
file_stream
)
>
after_open
;
...
...
@@ -265,7 +265,7 @@ typedef struct file_event_handlers
file_event_handlers
()
:
before_open
(
nullptr
),
after_open
(
nullptr
),
before_close
(
nullptr
),
after_close
(
nullptr
)
{}
}
file_event_handlers_t
;
};
namespace
details
{
// make_unique support for pre c++14
...
...
include/spdlog/details/file_helper-inl.h
View file @
5b7dfefc
...
...
@@ -20,7 +20,7 @@
namespace
spdlog
{
namespace
details
{
SPDLOG_INLINE
file_helper
::
file_helper
(
const
file_event_handlers
_t
&
event_handlers
)
SPDLOG_INLINE
file_helper
::
file_helper
(
const
file_event_handlers
&
event_handlers
)
:
event_handlers_
(
event_handlers
)
{}
...
...
include/spdlog/details/file_helper.h
View file @
5b7dfefc
...
...
@@ -17,7 +17,7 @@ class SPDLOG_API file_helper
{
public:
file_helper
()
=
default
;
explicit
file_helper
(
const
file_event_handlers
_t
&
event_handlers
);
explicit
file_helper
(
const
file_event_handlers
&
event_handlers
);
file_helper
(
const
file_helper
&
)
=
delete
;
file_helper
&
operator
=
(
const
file_helper
&
)
=
delete
;
...
...
@@ -51,7 +51,7 @@ private:
const
unsigned
int
open_interval_
=
10
;
std
::
FILE
*
fd_
{
nullptr
};
filename_t
filename_
;
file_event_handlers
_t
event_handlers_
;
file_event_handlers
event_handlers_
;
};
}
// namespace details
}
// namespace spdlog
...
...
include/spdlog/sinks/basic_file_sink-inl.h
View file @
5b7dfefc
...
...
@@ -14,7 +14,7 @@ namespace spdlog {
namespace
sinks
{
template
<
typename
Mutex
>
SPDLOG_INLINE
basic_file_sink
<
Mutex
>::
basic_file_sink
(
const
filename_t
&
filename
,
bool
truncate
,
const
file_event_handlers
_t
&
event_handlers
)
SPDLOG_INLINE
basic_file_sink
<
Mutex
>::
basic_file_sink
(
const
filename_t
&
filename
,
bool
truncate
,
const
file_event_handlers
&
event_handlers
)
:
file_helper_
{
event_handlers
}
{
file_helper_
.
open
(
filename
,
truncate
);
...
...
include/spdlog/sinks/basic_file_sink.h
View file @
5b7dfefc
...
...
@@ -20,7 +20,7 @@ template<typename Mutex>
class
basic_file_sink
final
:
public
base_sink
<
Mutex
>
{
public:
explicit
basic_file_sink
(
const
filename_t
&
filename
,
bool
truncate
=
false
,
const
file_event_handlers
_t
&
event_handlers
=
{});
explicit
basic_file_sink
(
const
filename_t
&
filename
,
bool
truncate
=
false
,
const
file_event_handlers
&
event_handlers
=
{});
const
filename_t
&
filename
()
const
;
protected:
...
...
@@ -40,13 +40,13 @@ using basic_file_sink_st = basic_file_sink<details::null_mutex>;
// factory functions
//
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
basic_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
const
file_event_handlers
_t
&
event_handlers
=
{})
inline
std
::
shared_ptr
<
logger
>
basic_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
basic_file_sink_mt
>(
logger_name
,
filename
,
truncate
,
event_handlers
);
}
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
basic_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
const
file_event_handlers
_t
&
event_handlers
=
{})
inline
std
::
shared_ptr
<
logger
>
basic_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
basic_file_sink_st
>(
logger_name
,
filename
,
truncate
,
event_handlers
);
}
...
...
include/spdlog/sinks/daily_file_sink.h
View file @
5b7dfefc
...
...
@@ -68,7 +68,7 @@ class daily_file_sink final : public base_sink<Mutex>
{
public:
// create daily file sink which rotates on given time
daily_file_sink
(
filename_t
base_filename
,
int
rotation_hour
,
int
rotation_minute
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
daily_file_sink
(
filename_t
base_filename
,
int
rotation_hour
,
int
rotation_minute
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
:
base_filename_
(
std
::
move
(
base_filename
))
,
rotation_h_
(
rotation_hour
)
,
rotation_m_
(
rotation_minute
)
...
...
@@ -215,28 +215,28 @@ using daily_file_format_sink_st = daily_file_sink<details::null_mutex, daily_fil
//
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
daily_file_sink_mt
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
,
max_files
,
event_handlers
);
}
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_format_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
daily_file_format_sink_mt
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
,
max_files
,
event_handlers
);
}
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
daily_file_sink_st
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
,
max_files
,
event_handlers
);
}
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_format_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
daily_file_format_sink_st
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
,
max_files
,
event_handlers
);
}
...
...
include/spdlog/sinks/hourly_file_sink.h
View file @
5b7dfefc
...
...
@@ -46,7 +46,7 @@ class hourly_file_sink final : public base_sink<Mutex>
{
public:
// create hourly file sink which rotates on given time
hourly_file_sink
(
filename_t
base_filename
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
hourly_file_sink
(
filename_t
base_filename
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
:
base_filename_
(
std
::
move
(
base_filename
))
,
file_helper_
{
event_handlers
}
,
truncate_
(
truncate
)
...
...
@@ -181,14 +181,14 @@ using hourly_file_sink_st = hourly_file_sink<details::null_mutex>;
//
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
hourly_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
hourly_file_sink_mt
>(
logger_name
,
filename
,
truncate
,
max_files
,
event_handlers
);
}
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
hourly_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
hourly_file_sink_st
>(
logger_name
,
filename
,
truncate
,
max_files
,
event_handlers
);
}
...
...
include/spdlog/sinks/rotating_file_sink-inl.h
View file @
5b7dfefc
...
...
@@ -25,7 +25,7 @@ namespace sinks {
template
<
typename
Mutex
>
SPDLOG_INLINE
rotating_file_sink
<
Mutex
>::
rotating_file_sink
(
filename_t
base_filename
,
std
::
size_t
max_size
,
std
::
size_t
max_files
,
bool
rotate_on_open
,
const
file_event_handlers
_t
&
event_handlers
)
filename_t
base_filename
,
std
::
size_t
max_size
,
std
::
size_t
max_files
,
bool
rotate_on_open
,
const
file_event_handlers
&
event_handlers
)
:
base_filename_
(
std
::
move
(
base_filename
))
,
max_size_
(
max_size
)
,
max_files_
(
max_files
)
...
...
include/spdlog/sinks/rotating_file_sink.h
View file @
5b7dfefc
...
...
@@ -22,7 +22,7 @@ template<typename Mutex>
class
rotating_file_sink
final
:
public
base_sink
<
Mutex
>
{
public:
rotating_file_sink
(
filename_t
base_filename
,
std
::
size_t
max_size
,
std
::
size_t
max_files
,
bool
rotate_on_open
=
false
,
const
file_event_handlers
_t
&
event_handlers
=
{});
rotating_file_sink
(
filename_t
base_filename
,
std
::
size_t
max_size
,
std
::
size_t
max_files
,
bool
rotate_on_open
=
false
,
const
file_event_handlers
&
event_handlers
=
{});
static
filename_t
calc_filename
(
const
filename_t
&
filename
,
std
::
size_t
index
);
filename_t
filename
();
...
...
@@ -60,14 +60,14 @@ using rotating_file_sink_st = rotating_file_sink<details::null_mutex>;
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
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
rotate_on_open
=
false
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
rotate_on_open
=
false
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
rotating_file_sink_mt
>(
logger_name
,
filename
,
max_file_size
,
max_files
,
rotate_on_open
,
event_handlers
);
}
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
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
rotate_on_open
=
false
,
const
file_event_handlers
_t
&
event_handlers
=
{})
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
size_t
max_file_size
,
size_t
max_files
,
bool
rotate_on_open
=
false
,
const
file_event_handlers
&
event_handlers
=
{})
{
return
Factory
::
template
create
<
sinks
::
rotating_file_sink_st
>(
logger_name
,
filename
,
max_file_size
,
max_files
,
rotate_on_open
,
event_handlers
);
}
...
...
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