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
8b7e19e9
Commit
8b7e19e9
authored
Jun 12, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes in pattern_formatter and async_logger
parent
81fa788b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
55 deletions
+9
-55
Makefile
example/Makefile
+1
-1
async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+1
-1
pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+7
-53
No files found.
example/Makefile
View file @
8b7e19e9
CXX
=
g++
CXX_FLAGS
=
-Wall
-W
shadow
-W
extra
-pedantic
-std
=
c++11
-pthread
-I
../include
CXX_FLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c++11
-pthread
-I
../include
CXX_RELEASE_FLAGS
=
-O3
-march
=
native
CXX_DEBUG_FLAGS
=
-g
...
...
include/spdlog/details/async_logger_impl.h
View file @
8b7e19e9
...
...
@@ -39,7 +39,7 @@ inline spdlog::async_logger::async_logger(
inline
void
spdlog
::
async_logger
::
sink_it_
(
details
::
log_msg
&
msg
)
{
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
_incr_msg_counter
(
msg
);
incr_msg_counter_
(
msg
);
#endif
if
(
auto
pool_ptr
=
thread_pool_
.
lock
())
{
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
8b7e19e9
...
...
@@ -51,7 +51,6 @@ class name_formatter : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// fmt::format_to(msg.formatted, *msg.logger_name);
append_str
(
*
msg
.
logger_name
,
msg
.
formatted
);
}
};
...
...
@@ -61,9 +60,7 @@ class level_formatter : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << level::to_str(msg.level);
auto
level_str
=
level
::
to_str
(
msg
.
level
);
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
level_str
);
append_str
(
level
::
to_str
(
msg
.
level
),
msg
.
formatted
);
}
};
...
...
@@ -72,9 +69,7 @@ class short_level_formatter : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << level::to_short_str(msg.level);
auto
level_str
=
level
::
to_short_str
(
msg
.
level
);
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
level_str
);
append_str
(
level
::
to_short_str
(
msg
.
level
),
msg
.
formatted
);
}
};
...
...
@@ -98,8 +93,7 @@ class a_formatter : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << days[tm_time.tm_wday];
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
days
[
tm_time
.
tm_wday
]);
append_str
(
days
[
tm_time
.
tm_wday
],
msg
.
formatted
);
}
};
...
...
@@ -109,8 +103,7 @@ class A_formatter : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << full_days[tm_time.tm_wday];
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
full_days
[
tm_time
.
tm_wday
]);
append_str
(
full_days
[
tm_time
.
tm_wday
],
msg
.
formatted
);
}
};
...
...
@@ -120,7 +113,6 @@ class b_formatter : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << months[tm_time.tm_mon];
append_str
(
months
[
tm_time
.
tm_mon
],
msg
.
formatted
);
}
};
...
...
@@ -132,7 +124,6 @@ class B_formatter : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << full_months[tm_time.tm_mon];
append_str
(
full_months
[
tm_time
.
tm_mon
],
msg
.
formatted
);
}
};
...
...
@@ -142,9 +133,6 @@ class c_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << days[tm_time.tm_wday] << ' ' << months[tm_time.tm_mon] << ' ' << tm_time.tm_mday << ' ';
// pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, ':') << ' ' << tm_time.tm_year + 1900;
fmt
::
format_to
(
msg
.
formatted
,
"{} {} {} {:02}:{:02}:{:02} {}"
,
days
[
tm_time
.
tm_wday
],
months
[
tm_time
.
tm_mon
],
tm_time
.
tm_mday
,
tm_time
.
tm_hour
,
tm_time
.
tm_min
,
tm_time
.
tm_sec
,
tm_time
.
tm_year
+
1900
);
}
...
...
@@ -155,7 +143,6 @@ class C_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << fmt::pad(tm_time.tm_year % 100, 2, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}"
,
tm_time
.
tm_year
%
100
);
}
};
...
...
@@ -165,7 +152,6 @@ class D_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// pad_n_join(msg.formatted, tm_time.tm_mon + 1, tm_time.tm_mday, tm_time.tm_year % 100, '/');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}/{:02}/{:02}"
,
tm_time
.
tm_mon
+
1
,
tm_time
.
tm_mday
,
tm_time
.
tm_year
%
100
);
}
};
...
...
@@ -175,7 +161,6 @@ class Y_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << tm_time.tm_year + 1900;
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
tm_time
.
tm_year
+
1900
);
}
};
...
...
@@ -185,7 +170,6 @@ class m_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << fmt::pad(tm_time.tm_mon + 1, 2, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}"
,
tm_time
.
tm_mon
+
1
);
}
};
...
...
@@ -195,7 +179,6 @@ class d_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << fmt::pad(tm_time.tm_mday, 2, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}"
,
tm_time
.
tm_mday
);
}
};
...
...
@@ -205,7 +188,6 @@ class H_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << fmt::pad(tm_time.tm_hour, 2, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}"
,
tm_time
.
tm_hour
);
}
};
...
...
@@ -215,7 +197,6 @@ class I_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << fmt::pad(to12h(tm_time), 2, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}"
,
to12h
(
tm_time
));
}
};
...
...
@@ -225,7 +206,6 @@ class M_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << fmt::pad(tm_time.tm_min, 2, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}"
,
tm_time
.
tm_min
);
}
};
...
...
@@ -235,7 +215,6 @@ class S_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << fmt::pad(tm_time.tm_sec, 2, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}"
,
tm_time
.
tm_sec
);
}
};
...
...
@@ -247,7 +226,6 @@ class e_formatter SPDLOG_FINAL : public flag_formatter
{
auto
duration
=
msg
.
time
.
time_since_epoch
();
auto
millis
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
duration
).
count
()
%
1000
;
// msg.formatted << fmt::pad(static_cast<int>(millis), 3, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:03}"
,
static_cast
<
int
>
(
millis
));
}
};
...
...
@@ -259,7 +237,6 @@ class f_formatter SPDLOG_FINAL : public flag_formatter
{
auto
duration
=
msg
.
time
.
time_since_epoch
();
auto
micros
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
duration
).
count
()
%
1000000
;
// msg.formatted << fmt::pad(static_cast<int>(micros), 6, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:06}"
,
static_cast
<
int
>
(
micros
));
}
};
...
...
@@ -271,8 +248,7 @@ class F_formatter SPDLOG_FINAL : public flag_formatter
{
auto
duration
=
msg
.
time
.
time_since_epoch
();
auto
ns
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
duration
).
count
()
%
1000000000
;
// msg.formatted << fmt::pad(static_cast<int>(ns), 9, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:06}"
,
static_cast
<
int
>
(
ns
));
fmt
::
format_to
(
msg
.
formatted
,
"{:09}"
,
static_cast
<
int
>
(
ns
));
}
};
...
...
@@ -282,7 +258,6 @@ class E_formatter SPDLOG_FINAL : public flag_formatter
{
auto
duration
=
msg
.
time
.
time_since_epoch
();
auto
seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
duration
).
count
();
// msg.formatted << seconds;
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
seconds
);
}
};
...
...
@@ -292,7 +267,6 @@ class p_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// msg.formatted << ampm(tm_time);
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
ampm
(
tm_time
));
}
};
...
...
@@ -302,8 +276,7 @@ class r_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// pad_n_join(msg.formatted, to12h(tm_time), tm_time.tm_min, tm_time.tm_sec, ':') << ' ' << ampm(tm_time);
fmt
::
format_to
(
msg
.
formatted
,
"{:02}:{:02}:{02} {}"
,
tm_time
.
tm_min
,
tm_time
.
tm_sec
,
ampm
(
tm_time
));
fmt
::
format_to
(
msg
.
formatted
,
"{:02}:{:02}:{:02} {}"
,
to12h
(
tm_time
),
tm_time
.
tm_min
,
tm_time
.
tm_sec
,
ampm
(
tm_time
));
}
};
...
...
@@ -312,7 +285,6 @@ class R_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, ':');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}:{:02}"
,
tm_time
.
tm_hour
,
tm_time
.
tm_min
);
}
};
...
...
@@ -322,8 +294,7 @@ class T_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
// pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, ':');
fmt
::
format_to
(
msg
.
formatted
,
"{:02}:{:02}"
,
tm_time
.
tm_min
,
tm_time
.
tm_sec
);
fmt
::
format_to
(
msg
.
formatted
,
"{:02}:{:02}:{:02}"
,
tm_time
.
tm_hour
,
tm_time
.
tm_min
,
tm_time
.
tm_sec
);
}
};
...
...
@@ -360,8 +331,6 @@ public:
int
h
=
total_minutes
/
60
;
int
m
=
total_minutes
%
60
;
// msg.formatted << sign;
// pad_n_join(msg.formatted, h, m, ':');
fmt
::
format_to
(
msg
.
formatted
,
"{}{:02}:{:02}"
,
sign
,
h
,
m
);
}
...
...
@@ -387,7 +356,6 @@ class t_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << msg.thread_id;
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
msg
.
thread_id
);
}
};
...
...
@@ -397,7 +365,6 @@ class pid_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << details::os::pid();
fmt
::
format_to
(
msg
.
formatted
,
"{}"
,
details
::
os
::
pid
());
}
};
...
...
@@ -407,7 +374,6 @@ class i_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << fmt::pad(msg.msg_id, 6, '0');
fmt
::
format_to
(
msg
.
formatted
,
"{:06}"
,
msg
.
msg_id
);
}
};
...
...
@@ -416,7 +382,6 @@ class v_formatter SPDLOG_FINAL : public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << fmt::StringRef(msg.raw.data(), msg.raw.size());
append_buf
(
msg
.
raw
,
msg
.
formatted
);
}
};
...
...
@@ -430,7 +395,6 @@ public:
}
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << ch_;
msg
.
formatted
.
push_back
(
ch_
);
}
...
...
@@ -450,7 +414,6 @@ public:
}
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
// msg.formatted << str_;
append_str
(
str_
,
msg
.
formatted
);
}
...
...
@@ -494,7 +457,6 @@ class full_formatter SPDLOG_FINAL : public flag_formatter
<< fmt::pad(static_cast<unsigned int>(millis), 3, '0') << "] ";
*/
// fmt::format_to(msg.formatted, "[{:d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:03d}] [{}] [{}] ",
fmt
::
format_to
(
msg
.
formatted
,
"[{}-{:02}-{:02} {:02}:{:02}:{:02}.{:03}] "
,
tm_time
.
tm_year
+
1900
,
tm_time
.
tm_mon
+
1
,
tm_time
.
tm_mday
,
tm_time
.
tm_hour
,
tm_time
.
tm_min
,
tm_time
.
tm_sec
,
static_cast
<
int
>
(
millis
));
...
...
@@ -504,21 +466,15 @@ class full_formatter SPDLOG_FINAL : public flag_formatter
#endif
#ifndef SPDLOG_NO_NAME
// msg.formatted << '[' << *msg.logger_name << "] ";
fmt
::
format_to
(
msg
.
formatted
,
"[{}] "
,
*
msg
.
logger_name
);
#endif
// msg.formatted << '[';
msg
.
formatted
.
push_back
(
'['
);
// wrap the level name with color
msg
.
color_range_start
=
msg
.
formatted
.
size
();
// msg.formatted << level::to_str(msg.level);
append_str
(
level
::
to_str
(
msg
.
level
),
msg
.
formatted
);
msg
.
color_range_end
=
msg
.
formatted
.
size
();
// msg.formatted << "] " << fmt::StringRef(msg.raw.data(), msg.raw.size());
msg
.
formatted
.
push_back
(
']'
);
msg
.
formatted
.
push_back
(
' '
);
append_buf
(
msg
.
raw
,
msg
.
formatted
);
...
...
@@ -741,7 +697,5 @@ inline void spdlog::pattern_formatter::format(details::log_msg &msg)
f
->
format
(
msg
,
tm_time
);
}
// write eol
// msg.formatted << eol_;
append_str
(
eol_
,
msg
.
formatted
);
}
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