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
b715378f
Commit
b715378f
authored
Apr 09, 2015
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tweakme.h - enable users to enable/disable features at compile time
parent
8da33db6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
34 deletions
+97
-34
common.h
include/spdlog/common.h
+0
-11
line_logger.h
include/spdlog/details/line_logger.h
+7
-0
os.h
include/spdlog/details/os.h
+6
-11
pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+12
-1
spdlog.h
include/spdlog/spdlog.h
+6
-11
tweakme.h
include/spdlog/tweakme.h
+66
-0
No files found.
include/spdlog/common.h
View file @
b715378f
...
...
@@ -36,18 +36,7 @@
#define SPDLOG_NOEXCEPT throw()
#endif
// under linux, you can use the much faster CLOCK_REALTIME_COARSE clock.
// this clock is less accurate - can be off by few millis - depending on the kernel HZ
// uncomment to use it instead of the regular (and slower) clock
//#ifdef __linux__
//#define SPDLOG_CLOCK_COARSE
//#endif
// uncomment if thread id logging is needed - to gain few nanos
// #define SPDLOG_NO_THREAD_ID
//
namespace
spdlog
{
...
...
include/spdlog/details/line_logger.h
View file @
b715378f
...
...
@@ -62,9 +62,16 @@ public:
{
if
(
_enabled
)
{
#ifndef SPDLOG_NO_NAME
_log_msg
.
logger_name
=
_callback_logger
->
name
();
#endif
#ifndef SPDLOG_NO_DATETIME
_log_msg
.
time
=
os
::
now
();
#endif
#ifndef SPDLOG_NO_THREAD_ID
_log_msg
.
thread_id
=
os
::
thread_id
();
#endif
_callback_logger
->
_log_msg
(
_log_msg
);
}
}
...
...
include/spdlog/details/os.h
View file @
b715378f
...
...
@@ -51,7 +51,7 @@ namespace os
inline
spdlog
::
log_clock
::
time_point
now
()
{
#if
def
SPDLOG_CLOCK_COARSE
#if
defined __linux__ && defined
SPDLOG_CLOCK_COARSE
timespec
ts
;
::
clock_gettime
(
CLOCK_REALTIME_COARSE
,
&
ts
);
return
std
::
chrono
::
time_point
<
log_clock
,
typename
log_clock
::
duration
>
(
...
...
@@ -175,19 +175,14 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
//It exists because the std::this_thread::get_id() is much slower(espcially under VS 2013)
inline
size_t
thread_id
()
{
#ifdef SPDLOG_NO_THREAD_ID
return
0
;
#else
#ifdef _WIN32
return
::
GetCurrentThreadId
(
);
return
static_cast
<
size_t
>
(
::
GetCurrentThreadId
()
);
#elif __linux__
return
s
yscall
(
SYS_gettid
);
#else
return
pthread_self
(
);
return
s
tatic_cast
<
size_t
>
(
syscall
(
SYS_gettid
)
);
#else
//Default to standard C++11 (OSX and other Unix)
return
static_cast
<
size_t
>
(
std
::
hash
<
std
::
thread
::
id
>
()(
std
::
this_thread
::
get_id
())
);
#endif
#endif //SPDLOG_NO_THREAD_ID
}
}
//os
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
b715378f
...
...
@@ -405,6 +405,7 @@ class full_formatter :public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
#ifndef SPDLOG_NO_DATETIME
auto
duration
=
msg
.
time
.
time_since_epoch
();
auto
millis
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
duration
).
count
()
%
1000
;
...
...
@@ -421,6 +422,7 @@ class full_formatter :public flag_formatter
level::to_str(msg.level),
msg.raw.str());*/
// Faster (albeit uglier) way to format the line (5.6 million lines/sec under 10 threads)
msg
.
formatted
<<
'['
<<
static_cast
<
unsigned
int
>
(
tm_time
.
tm_year
+
1900
)
<<
'-'
<<
fmt
::
pad
(
static_cast
<
unsigned
int
>
(
tm_time
.
tm_mon
+
1
),
2
,
'0'
)
<<
'-'
...
...
@@ -430,7 +432,16 @@ class full_formatter :public flag_formatter
<<
fmt
::
pad
(
static_cast
<
unsigned
int
>
(
tm_time
.
tm_sec
),
2
,
'0'
)
<<
'.'
<<
fmt
::
pad
(
static_cast
<
unsigned
int
>
(
millis
),
3
,
'0'
)
<<
"] "
;
msg
.
formatted
<<
'['
<<
msg
.
logger_name
<<
"] ["
<<
level
::
to_str
(
msg
.
level
)
<<
"] "
;
//no datetime needed
#else
(
void
)
tm_time
;
#endif;
#ifndef SPDLOG_NO_NAME
msg
.
formatted
<<
'['
<<
msg
.
logger_name
<<
"] "
;
#endif
msg
.
formatted
<<
'['
<<
level
::
to_str
(
msg
.
level
)
<<
"] "
;
msg
.
formatted
<<
fmt
::
StringRef
(
msg
.
raw
.
data
(),
msg
.
raw
.
size
());
}
};
...
...
include/spdlog/spdlog.h
View file @
b715378f
...
...
@@ -28,6 +28,7 @@
#pragma once
#include "tweakme.h"
#include "common.h"
#include "logger.h"
...
...
@@ -121,16 +122,17 @@ void drop(const std::string &name);
void
drop_all
();
//
//
/////////////////////////////////////////////////////////////////////////////
//
// Macros to be display source file & line
// Trace & Debug can be switched on/off at compile time for zero cost debug statements.
// Uncomment SPDLOG_DEBUG_ON/SPDLOG_TRACE_ON in teakme.h to enable.
//
// Example:
// #define SPDLOG_DEBUG_ON
// include "spdlog/spdlog.h"
// spdlog::set_level(spdlog::level::debug);
// SPDLOG_DEBUG(my_logger, "Some debug message {} {}", 1, 3.2);
//
///////////////////////////////////////////////////////////////////////////////
#ifdef SPDLOG_TRACE_ON
#define SPDLOG_TRACE(logger, ...) logger->trace(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#else
...
...
@@ -143,13 +145,6 @@ void drop_all();
#define SPDLOG_DEBUG(logger, ...)
#endif
#define SPDLOG_INFO(logger, ...) logger->info(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_NOTICE(logger, ...) logger->notice(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_WARN(logger, ...) logger->warn(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_ERROR(logger, ...) logger->error(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_CRITICAL(logger, ...) logger->critical(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_ALERT(logger, ...) logger->alert(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_EMERG(logger, ...) logger->emerg(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
}
...
...
include/spdlog/tweakme.h
0 → 100644
View file @
b715378f
/*************************************************************************/
/* spdlog - an extremely fast and easy to use c++11 logging library. */
/* Copyright (c) 2014 Gabi Melman. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#pragma once
///////////////////////////////////////////////////////////////////////////////
// Edit this file to squeeze every last drop of performance out of spdlog.
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Under Linux, the much faster CLOCK_REALTIME_COARSE clock can be used.
// This clock is less accurate - can be off by dozens millis - depending on the kernel HZ
// Uncomment to use it instead of the regular (but slower) clock.
// #define SPDLOG_CLOCK_COARSE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if date/time logging is not needed.
// This will prevent spdlog from quering the system clock on each log call.
// #define SPDLOG_NO_DATETIME
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if thread id logging is not needed (i.e. no %t in the log pattern)
// This will prevent spdlog from quering the thread id on each log call.
// #define SPDLOG_NO_THREAD_ID
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if logger name logging is not needed.
// This will prevent spdlog from copying the logger name on each log call.
// #define SPDLOG_NO_NAME
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable the SPDLOG_DEBUG/SPDLOG_TRACE macros
// #define SPDLOG_DEBUG_ON
// #define SPDLOG_TRACE_ON
///////////////////////////////////////////////////////////////////////////////
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