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
c68a0de2
Commit
c68a0de2
authored
Aug 22, 2016
by
Gabi Melman
Committed by
GitHub
Aug 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #263 from jan-dx/master
Add support for Solaris operating system
parents
e556daeb
097ba5a3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
10 deletions
+64
-10
example/example.cpp
example/example.cpp
+1
-1
include/spdlog/common.h
include/spdlog/common.h
+10
-0
include/spdlog/details/os.h
include/spdlog/details/os.h
+40
-5
include/spdlog/details/spdlog_impl.h
include/spdlog/details/spdlog_impl.h
+1
-1
include/spdlog/sinks/syslog_sink.h
include/spdlog/sinks/syslog_sink.h
+3
-2
include/spdlog/spdlog.h
include/spdlog/spdlog.h
+1
-1
include/spdlog/tweakme.h
include/spdlog/tweakme.h
+8
-0
No files found.
example/example.cpp
View file @
c68a0de2
...
...
@@ -108,7 +108,7 @@ void async_example()
//syslog example (linux/osx/freebsd)
void
syslog_example
()
{
#if
defined (__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#if
def SPDLOG_ENABLE_SYSLOG
std
::
string
ident
=
"spdlog-example"
;
auto
syslog_logger
=
spd
::
syslog_logger
(
"syslog"
,
ident
,
LOG_PID
);
syslog_logger
->
warn
(
"This is warning that will end up in syslog."
);
...
...
include/spdlog/common.h
View file @
c68a0de2
...
...
@@ -37,6 +37,16 @@
#define DEPRECATED
#endif
#include <spdlog/tweakme.h>
#ifndef SPDLOG_ENABLE_SYSLOG
#if defined (__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#define SPDLOG_ENABLE_SYSLOG
#elif defined(sun) || defined(__sun)
#define SPDLOG_ENABLE_SYSLOG
#endif
#endif
#include <spdlog/fmt/fmt.h>
...
...
include/spdlog/details/os.h
View file @
c68a0de2
...
...
@@ -250,7 +250,42 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
offset
-=
tzinfo
.
StandardBias
;
return
offset
;
#else
return
static_cast
<
int
>
(
tm
.
tm_gmtoff
/
60
);
long
int
offset_seconds
;
#if defined(sun) || defined(__sun)
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
struct
helper
{
static
long
int
calculate_gmt_offset
(
const
std
::
tm
&
localtm
=
details
::
os
::
localtime
(),
const
std
::
tm
&
gmtm
=
details
::
os
::
gmtime
())
{
int
local_year
=
localtm
.
tm_year
+
(
1900
-
1
);
int
gmt_year
=
gmtm
.
tm_year
+
(
1900
-
1
);
long
int
days
=
(
// difference in day of year
localtm
.
tm_yday
-
gmtm
.
tm_yday
// + intervening leap days
+
((
local_year
>>
2
)
-
(
gmt_year
>>
2
))
-
(
local_year
/
100
-
gmt_year
/
100
)
+
((
local_year
/
100
>>
2
)
-
(
gmt_year
/
100
>>
2
))
// + difference in years * 365 */
+
(
long
int
)(
local_year
-
gmt_year
)
*
365
);
long
int
hours
=
(
24
*
days
)
+
(
localtm
.
tm_hour
-
gmtm
.
tm_hour
);
long
int
mins
=
(
60
*
hours
)
+
(
localtm
.
tm_min
-
gmtm
.
tm_min
);
long
int
secs
=
(
60
*
mins
)
+
(
localtm
.
tm_sec
-
gmtm
.
tm_sec
);
return
secs
;
}
};
offset_seconds
=
helper
::
calculate_gmt_offset
(
tm
);
#else
offset_seconds
=
tm
.
tm_gmtoff
;
#endif
return
static_cast
<
int
>
(
offset_seconds
/
60
);
#endif
}
...
...
include/spdlog/details/spdlog_impl.h
View file @
c68a0de2
...
...
@@ -96,7 +96,7 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::strin
return
create_console_logger
(
logger_name
,
sinks
::
stderr_sink_st
::
instance
(),
color
);
}
#if
defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#if
def SPDLOG_ENABLE_SYSLOG
// Create syslog logger
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
syslog_logger
(
const
std
::
string
&
logger_name
,
const
std
::
string
&
syslog_ident
,
int
syslog_option
)
{
...
...
include/spdlog/sinks/syslog_sink.h
View file @
c68a0de2
...
...
@@ -5,10 +5,11 @@
#pragma once
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#include <spdlog/common.h>
#ifdef SPDLOG_ENABLE_SYSLOG
#include <spdlog/sinks/sink.h>
#include <spdlog/common.h>
#include <spdlog/details/log_msg.h>
#include <array>
...
...
include/spdlog/spdlog.h
View file @
c68a0de2
...
...
@@ -98,7 +98,7 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name, bool co
//
// Create and register a syslog logger
//
#if
defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#if
def SPDLOG_ENABLE_SYSLOG
std
::
shared_ptr
<
logger
>
syslog_logger
(
const
std
::
string
&
logger_name
,
const
std
::
string
&
ident
=
""
,
int
syslog_option
=
0
);
#endif
...
...
include/spdlog/tweakme.h
View file @
c68a0de2
...
...
@@ -11,6 +11,14 @@
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// By default, syslog sink is only enabled on tested operating systems.
// Uncomment to enable it unconditionally.
//
// #define SPDLOG_ENABLE_SYSLOG
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Under Linux, the much faster CLOCK_REALTIME_COARSE clock can be used.
// This clock is less accurate - can be off by dozens of millis - depending on the kernel HZ.
...
...
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