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
a16ff07a
Commit
a16ff07a
authored
Nov 24, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show source location if present in default formatter
parent
3218caf3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
18 deletions
+28
-18
common.h
include/spdlog/common.h
+1
-1
pattern_formatter.h
include/spdlog/details/pattern_formatter.h
+27
-17
No files found.
include/spdlog/common.h
View file @
a16ff07a
...
...
@@ -198,7 +198,7 @@ struct source_loc
{
}
SPDLOG_CONSTEXPR
bool
empty
()
const
SPDLOG_CONSTEXPR
bool
empty
()
const
SPDLOG_NOEXCEPT
{
return
line
==
0
;
}
...
...
include/spdlog/details/pattern_formatter.h
View file @
a16ff07a
...
...
@@ -817,10 +817,10 @@ public:
void
format
(
const
details
::
log_msg
&
msg
,
const
std
::
tm
&
,
fmt
::
memory_buffer
&
dest
)
override
{
if
(
msg
.
source
.
empty
())
{
return
;
}
if
(
msg
.
source
.
empty
())
{
return
;
}
if
(
padinfo_
.
width_
)
{
const
auto
text_size
=
std
::
char_traits
<
char
>::
length
(
msg
.
source
.
filename
)
+
fmt_helper
::
count_digits
(
msg
.
source
.
line
)
+
1
;
...
...
@@ -846,7 +846,7 @@ public:
void
format
(
const
details
::
log_msg
&
msg
,
const
std
::
tm
&
,
fmt
::
memory_buffer
&
dest
)
override
{
if
(
msg
.
source
.
empty
())
if
(
msg
.
source
.
empty
())
{
return
;
}
...
...
@@ -863,7 +863,7 @@ public:
void
format
(
const
details
::
log_msg
&
msg
,
const
std
::
tm
&
,
fmt
::
memory_buffer
&
dest
)
override
{
if
(
msg
.
source
.
empty
())
if
(
msg
.
source
.
empty
())
{
return
;
}
...
...
@@ -891,11 +891,12 @@ public:
}
void
format
(
const
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
,
fmt
::
memory_buffer
&
dest
)
override
{
{
using
std
::
chrono
::
duration_cast
;
using
std
::
chrono
::
milliseconds
;
using
std
::
chrono
::
seconds
;
#ifndef SPDLOG_NO_DATETIME
// cache the date/time part for the next second.
...
...
@@ -930,8 +931,9 @@ public:
auto
millis
=
fmt_helper
::
time_fraction
<
milliseconds
>
(
msg
.
time
);
fmt_helper
::
pad3
(
static_cast
<
uint32_t
>
(
millis
.
count
()),
dest
);
dest
.
push_back
(
']'
);
dest
.
push_back
(
' '
);
SPDLOG_CONSTEXPR
string_view_t
closing_bracket
{
"] "
};
fmt_helper
::
append_string_view
(
closing_bracket
,
dest
);
#else // no datetime needed
(
void
)
tm_time
;
...
...
@@ -943,8 +945,7 @@ public:
dest
.
push_back
(
'['
);
// fmt_helper::append_str(*msg.logger_name, dest);
fmt_helper
::
append_string_view
(
*
msg
.
logger_name
,
dest
);
dest
.
push_back
(
']'
);
dest
.
push_back
(
' '
);
fmt_helper
::
append_string_view
(
closing_bracket
,
dest
);
}
#endif
...
...
@@ -954,8 +955,17 @@ public:
// fmt_helper::append_string_view(level::to_c_str(msg.level), dest);
fmt_helper
::
append_string_view
(
level
::
to_c_str
(
msg
.
level
),
dest
);
msg
.
color_range_end
=
dest
.
size
();
dest
.
push_back
(
']'
);
dest
.
push_back
(
' '
);
fmt_helper
::
append_string_view
(
closing_bracket
,
dest
);
// add soruce location if present
if
(
!
msg
.
source
.
empty
())
{
dest
.
push_back
(
'['
);
fmt_helper
::
append_string_view
(
msg
.
source
.
filename
,
dest
);
dest
.
push_back
(
':'
);
fmt_helper
::
append_int
(
msg
.
source
.
line
,
dest
);
fmt_helper
::
append_string_view
(
closing_bracket
,
dest
);
}
// fmt_helper::append_string_view(msg.msg(), dest);
fmt_helper
::
append_string_view
(
msg
.
payload
,
dest
);
}
...
...
@@ -1040,11 +1050,11 @@ private:
{
switch
(
flag
)
{
case
(
'+'
):
// default formatter
case
(
'+'
):
// default formatter
formatters_
.
push_back
(
details
::
make_unique
<
details
::
full_formatter
>
(
padding
));
break
;
case
'n'
:
// logger name
formatters_
.
push_back
(
details
::
make_unique
<
details
::
name_formatter
>
(
padding
));
break
;
...
...
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