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
10d5292b
Commit
10d5292b
authored
May 15, 2016
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better support for custom eol
parent
6760dceb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
31 deletions
+16
-31
include/spdlog/common.h
include/spdlog/common.h
+3
-1
include/spdlog/details/os.h
include/spdlog/details/os.h
+8
-19
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+1
-5
include/spdlog/tweakme.h
include/spdlog/tweakme.h
+2
-2
tests/format.cpp
tests/format.cpp
+2
-4
No files found.
include/spdlog/common.h
View file @
10d5292b
...
...
@@ -20,11 +20,13 @@
#include <spdlog/details/null_mutex.h>
//visual studio upto 2013 does not support noexcept
//visual studio upto 2013 does not support noexcept
nor constexpr
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define SPDLOG_NOEXCEPT throw()
#define SPDLOG_CONSTEXPR
#else
#define SPDLOG_NOEXCEPT noexcept
#define SPDLOG_CONSTEXPR constexpr
#endif
...
...
include/spdlog/details/os.h
View file @
10d5292b
...
...
@@ -112,30 +112,19 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
return
!
(
tm1
==
tm2
);
}
// eol at end of each log line
#if !defined (SPDLOG_EOL)
#ifdef _WIN32
inline
const
char
*
eol
()
{
return
"
\r\n
"
;
}
#define SPDLOG_EOL "\r\n"
#else
constexpr
inline
const
char
*
eol
()
{
return
"
\n
"
;
}
#define SPDLOG_EOL "\n"
#endif
#ifdef _WIN32
inline
unsigned
short
eol_size
()
{
return
2
;
}
#else
constexpr
inline
unsigned
short
eol_size
()
{
return
1
;
}
#endif
SPDLOG_CONSTEXPR
static
const
char
*
eol
=
SPDLOG_EOL
;
SPDLOG_CONSTEXPR
static
int
eol_size
=
sizeof
(
SPDLOG_EOL
)
-
1
;
//fopen_s on non windows for writing
inline
int
fopen_s
(
FILE
**
fp
,
const
filename_t
&
filename
,
const
filename_t
&
mode
)
{
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
10d5292b
...
...
@@ -619,11 +619,7 @@ inline void spdlog::pattern_formatter::format(details::log_msg& msg)
f
->
format
(
msg
,
tm_time
);
}
//write eol
#if defined(SPDLOG_EOL)
msg
.
formatted
<<
SPDLOG_EOL
;
#else
msg
.
formatted
.
write
(
details
::
os
::
eol
(),
details
::
os
::
eol_size
());
#endif
msg
.
formatted
.
write
(
details
::
os
::
eol
,
details
::
os
::
eol_size
);
}
catch
(
const
fmt
::
FormatError
&
e
)
{
...
...
include/spdlog/tweakme.h
View file @
10d5292b
...
...
@@ -65,6 +65,6 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
uncomment the below to override spdlog's default eol
// #define SPDLOG_EOL "\n"
//
Uncomment to override default eol ("\n" or "\r\n" under Linux/Windows)
// #define SPDLOG_EOL "
;-)
\n"
///////////////////////////////////////////////////////////////////////////////
tests/format.cpp
View file @
10d5292b
...
...
@@ -12,10 +12,8 @@ std::string log_info(const T& what, spdlog::level::level_enum logger_level = spd
oss_logger
.
set_level
(
logger_level
);
oss_logger
.
set_pattern
(
"%v"
);
oss_logger
.
info
()
<<
what
;
//strip last eol and return the logged string
auto
eol_size
=
strlen
(
spdlog
::
details
::
os
::
eol
());
return
oss
.
str
().
substr
(
0
,
oss
.
str
().
length
()
-
eol_size
);
return
oss
.
str
().
substr
(
0
,
oss
.
str
().
length
()
-
spdlog
::
details
::
os
::
eol_size
);
}
...
...
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