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
bce33698
Unverified
Commit
bce33698
authored
Feb 23, 2018
by
Gabi Melman
Committed by
GitHub
Feb 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #628 from emadwill/eol
Support for custom EOL per formatter -Thanks @emadwill
parents
04d0dd59
55680db1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
8 deletions
+8
-8
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+1
-1
include/spdlog/details/os.h
include/spdlog/details/os.h
+1
-2
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+3
-3
include/spdlog/formatter.h
include/spdlog/formatter.h
+2
-1
tests/format.cpp
tests/format.cpp
+1
-1
No files found.
include/spdlog/details/logger_impl.h
View file @
bce33698
...
...
@@ -350,7 +350,7 @@ inline void spdlog::logger::_default_err_handler(const std::string &msg)
char
date_buf
[
100
];
std
::
strftime
(
date_buf
,
sizeof
(
date_buf
),
"%Y-%m-%d %H:%M:%S"
,
&
tm_time
);
details
::
log_msg
err_msg
;
err_msg
.
formatted
.
write
(
"[*** LOG ERROR ***] [{}] [{}] [{}]{}"
,
name
(),
msg
,
date_buf
,
details
::
os
::
eol
);
err_msg
.
formatted
.
write
(
"[*** LOG ERROR ***] [{}] [{}] [{}]{}"
,
name
(),
msg
,
date_buf
,
details
::
os
::
default_
eol
);
sinks
::
stderr_sink_mt
::
instance
()
->
log
(
err_msg
);
_last_err_time
=
now
;
}
...
...
include/spdlog/details/os.h
View file @
bce33698
...
...
@@ -140,8 +140,7 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
#endif
#endif
SPDLOG_CONSTEXPR
static
const
char
*
eol
=
SPDLOG_EOL
;
SPDLOG_CONSTEXPR
static
int
eol_size
=
sizeof
(
SPDLOG_EOL
)
-
1
;
SPDLOG_CONSTEXPR
static
const
char
*
default_eol
=
SPDLOG_EOL
;
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
bce33698
...
...
@@ -487,8 +487,8 @@ class full_formatter SPDLOG_FINAL:public flag_formatter
///////////////////////////////////////////////////////////////////////////////
// pattern_formatter inline impl
///////////////////////////////////////////////////////////////////////////////
inline
spdlog
::
pattern_formatter
::
pattern_formatter
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
)
:
_pattern_time
(
pattern_time
)
inline
spdlog
::
pattern_formatter
::
pattern_formatter
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
,
std
::
string
eol
)
:
_
eol
(
move
(
eol
)),
_
pattern_time
(
pattern_time
)
{
compile_pattern
(
pattern
);
}
...
...
@@ -681,5 +681,5 @@ inline void spdlog::pattern_formatter::format(details::log_msg& msg)
f
->
format
(
msg
,
tm_time
);
}
//write eol
msg
.
formatted
.
write
(
details
::
os
::
eol
,
details
::
os
::
eol_size
);
msg
.
formatted
.
write
(
_eol
.
data
(),
_eol
.
size
()
);
}
include/spdlog/formatter.h
View file @
bce33698
...
...
@@ -29,11 +29,12 @@ class pattern_formatter SPDLOG_FINAL : public formatter
{
public:
explicit
pattern_formatter
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
=
pattern_time_type
::
local
);
explicit
pattern_formatter
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
=
pattern_time_type
::
local
,
const
std
::
string
eol
=
spdlog
::
details
::
os
::
default_eol
);
pattern_formatter
(
const
pattern_formatter
&
)
=
delete
;
pattern_formatter
&
operator
=
(
const
pattern_formatter
&
)
=
delete
;
void
format
(
details
::
log_msg
&
msg
)
override
;
private:
const
std
::
string
_eol
;
const
std
::
string
_pattern
;
const
pattern_time_type
_pattern_time
;
std
::
vector
<
std
::
unique_ptr
<
details
::
flag_formatter
>>
_formatters
;
...
...
tests/format.cpp
View file @
bce33698
...
...
@@ -13,7 +13,7 @@ std::string log_info(const T& what, spdlog::level::level_enum logger_level = spd
oss_logger
.
set_pattern
(
"%v"
);
oss_logger
.
info
(
what
);
return
oss
.
str
().
substr
(
0
,
oss
.
str
().
length
()
-
s
pdlog
::
details
::
os
::
eol_size
);
return
oss
.
str
().
substr
(
0
,
oss
.
str
().
length
()
-
s
trlen
(
spdlog
::
details
::
os
::
default_eol
)
);
}
...
...
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