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
ece27ac9
Commit
ece27ac9
authored
Nov 22, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
astyle
parent
a9dbfb8b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
60 deletions
+61
-60
example.cpp
example/example.cpp
+4
-4
common.h
include/spdlog/common.h
+3
-2
file_helper.h
include/spdlog/details/file_helper.h
+4
-4
file_sinks.h
include/spdlog/sinks/file_sinks.h
+6
-6
syslog_sink.h
include/spdlog/sinks/syslog_sink.h
+43
-43
spdlog.h
include/spdlog/spdlog.h
+1
-1
No files found.
example/example.cpp
View file @
ece27ac9
...
...
@@ -64,10 +64,10 @@ int main(int, char* [])
SPDLOG_TRACE
(
file_logger
,
"This is a trace message (only #ifdef _DEBUG)"
,
123
);
#ifdef __linux__
auto
syslog_logger
=
spd
::
syslog_logger
(
"syslog"
);
syslog_logger
->
warn
(
"This is warning that will end up in syslog. This is Linux only!"
);
#endif
#ifdef __linux__
auto
syslog_logger
=
spd
::
syslog_logger
(
"syslog"
);
syslog_logger
->
warn
(
"This is warning that will end up in syslog. This is Linux only!"
);
#endif
}
catch
(
const
spd
::
spdlog_ex
&
ex
)
{
...
...
include/spdlog/common.h
View file @
ece27ac9
...
...
@@ -50,7 +50,7 @@ typedef enum
DEBUG
=
1
,
INFO
=
2
,
NOTICE
=
3
,
WARN
=
4
,
WARN
=
4
,
ERR
=
5
,
CRITICAL
=
6
,
ALERT
=
7
,
...
...
@@ -60,7 +60,8 @@ typedef enum
}
level_enum
;
static
const
char
*
level_names
[]
{
"trace"
,
"debug"
,
"info"
,
"notice"
,
"warning"
,
"error"
,
"critical"
,
"alert"
,
"emerg"
,
""
,
""
};
"alert"
,
"emerg"
,
""
,
""
};
inline
const
char
*
to_str
(
spdlog
::
level
::
level_enum
l
)
{
return
level_names
[
l
];
...
...
include/spdlog/details/file_helper.h
View file @
ece27ac9
...
...
@@ -82,10 +82,10 @@ public:
void
reopen
()
{
if
(
_filename
.
empty
())
throw
spdlog_ex
(
"Failed re opening file - was not opened before"
);
open
(
_filename
);
if
(
_filename
.
empty
())
throw
spdlog_ex
(
"Failed re opening file - was not opened before"
);
open
(
_filename
);
}
void
close
()
...
...
include/spdlog/sinks/file_sinks.h
View file @
ece27ac9
...
...
@@ -125,12 +125,12 @@ private:
std
::
string
target
=
calc_filename
(
_base_filename
,
i
,
_extension
);
if
(
details
::
file_helper
::
file_exists
(
target
))
{
if
(
std
::
remove
(
target
.
c_str
())
!=
0
)
{
throw
spdlog_ex
(
"rotating_file_sink: failed removing "
+
target
);
}
}
{
if
(
std
::
remove
(
target
.
c_str
())
!=
0
)
{
throw
spdlog_ex
(
"rotating_file_sink: failed removing "
+
target
);
}
}
if
(
details
::
file_helper
::
file_exists
(
src
)
&&
std
::
rename
(
src
.
c_str
(),
target
.
c_str
()))
{
throw
spdlog_ex
(
"rotating_file_sink: failed renaming "
+
src
+
" to "
+
target
);
...
...
include/spdlog/sinks/syslog_sink.h
View file @
ece27ac9
...
...
@@ -35,54 +35,54 @@
namespace
spdlog
{
namespace
sinks
{
/**
* Sink that write to syslog using the `syscall()` library call.
*
* Locking is not needed, as `syslog()` itself is thread-safe.
*/
class
syslog_sink
:
public
sink
namespace
sinks
{
/**
* Sink that write to syslog using the `syscall()` library call.
*
* Locking is not needed, as `syslog()` itself is thread-safe.
*/
class
syslog_sink
:
public
sink
{
public
:
syslog_sink
()
{
public
:
syslog_sink
()
{
_priorities
[
static_cast
<
int
>
(
level
::
TRACE
)]
=
LOG_DEBUG
;
_priorities
[
static_cast
<
int
>
(
level
::
DEBUG
)]
=
LOG_DEBUG
;
_priorities
[
static_cast
<
int
>
(
level
::
INFO
)]
=
LOG_INFO
;
_priorities
[
static_cast
<
int
>
(
level
::
NOTICE
)]
=
LOG_NOTICE
;
_priorities
[
static_cast
<
int
>
(
level
::
WARN
)]
=
LOG_WARNING
;
_priorities
[
static_cast
<
int
>
(
level
::
ERR
)]
=
LOG_ERR
;
_priorities
[
static_cast
<
int
>
(
level
::
CRITICAL
)]
=
LOG_CRIT
;
_priorities
[
static_cast
<
int
>
(
level
::
ALERT
)]
=
LOG_ALERT
;
_priorities
[
static_cast
<
int
>
(
level
::
EMERG
)]
=
LOG_EMERG
;
_priorities
[
static_cast
<
int
>
(
level
::
TRACE
)]
=
LOG_DEBUG
;
_priorities
[
static_cast
<
int
>
(
level
::
DEBUG
)]
=
LOG_DEBUG
;
_priorities
[
static_cast
<
int
>
(
level
::
INFO
)]
=
LOG_INFO
;
_priorities
[
static_cast
<
int
>
(
level
::
NOTICE
)]
=
LOG_NOTICE
;
_priorities
[
static_cast
<
int
>
(
level
::
WARN
)]
=
LOG_WARNING
;
_priorities
[
static_cast
<
int
>
(
level
::
ERR
)]
=
LOG_ERR
;
_priorities
[
static_cast
<
int
>
(
level
::
CRITICAL
)]
=
LOG_CRIT
;
_priorities
[
static_cast
<
int
>
(
level
::
ALERT
)]
=
LOG_ALERT
;
_priorities
[
static_cast
<
int
>
(
level
::
EMERG
)]
=
LOG_EMERG
;
_priorities
[
static_cast
<
int
>
(
level
::
ALWAYS
)]
=
LOG_INFO
;
_priorities
[
static_cast
<
int
>
(
level
::
OFF
)]
=
LOG_INFO
;
}
virtual
~
syslog_sink
()
=
default
;
syslog_sink
(
const
syslog_sink
&
)
=
delete
;
syslog_sink
&
operator
=
(
const
syslog_sink
&
)
=
delete
;
void
log
(
const
details
::
log_msg
&
msg
)
override
{
syslog
(
syslog_prio_from_level
(
msg
),
"%s"
,
msg
.
formatted
.
str
().
c_str
());
};
_priorities
[
static_cast
<
int
>
(
level
::
ALWAYS
)]
=
LOG_INFO
;
_priorities
[
static_cast
<
int
>
(
level
::
OFF
)]
=
LOG_INFO
;
}
virtual
~
syslog_sink
()
=
default
;
protected
:
/**
* Simply maps spdlog's log level to syslog priority level.
*/
int
syslog_prio_from_level
(
const
details
::
log_msg
&
msg
)
const
{
return
_priorities
[
static_cast
<
int
>
(
msg
.
level
)];
}
syslog_sink
(
const
syslog_sink
&
)
=
delete
;
syslog_sink
&
operator
=
(
const
syslog_sink
&
)
=
delete
;
private
:
std
::
array
<
int
,
11
>
_priorities
;
void
log
(
const
details
::
log_msg
&
msg
)
override
{
syslog
(
syslog_prio_from_level
(
msg
),
"%s"
,
msg
.
formatted
.
str
().
c_str
());
};
}
protected
:
/**
* Simply maps spdlog's log level to syslog priority level.
*/
int
syslog_prio_from_level
(
const
details
::
log_msg
&
msg
)
const
{
return
_priorities
[
static_cast
<
int
>
(
msg
.
level
)];
}
private
:
std
::
array
<
int
,
11
>
_priorities
;
};
}
}
#endif
include/spdlog/spdlog.h
View file @
ece27ac9
...
...
@@ -70,7 +70,7 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name);
// Create a syslog logger
#ifdef __linux__
std
::
shared_ptr
<
logger
>
syslog_logger
(
const
std
::
string
&
logger_name
);
std
::
shared_ptr
<
logger
>
syslog_logger
(
const
std
::
string
&
logger_name
);
#endif
...
...
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