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
5d5f2f3a
Commit
5d5f2f3a
authored
May 31, 2017
by
Gabi Melman
Committed by
GitHub
May 31, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #451 from ThePhD/pattern_time
UTC Time
parents
13fb2550
7e09f018
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
13 deletions
+31
-13
include/spdlog/async_logger.h
include/spdlog/async_logger.h
+1
-1
include/spdlog/common.h
include/spdlog/common.h
+9
-0
include/spdlog/details/async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+2
-2
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+4
-4
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+10
-3
include/spdlog/formatter.h
include/spdlog/formatter.h
+3
-1
include/spdlog/logger.h
include/spdlog/logger.h
+2
-2
No files found.
include/spdlog/async_logger.h
View file @
5d5f2f3a
...
...
@@ -71,7 +71,7 @@ public:
protected:
void
_sink_it
(
details
::
log_msg
&
msg
)
override
;
void
_set_formatter
(
spdlog
::
formatter_ptr
msg_formatter
)
override
;
void
_set_pattern
(
const
std
::
string
&
pattern
)
override
;
void
_set_pattern
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
)
override
;
private:
std
::
unique_ptr
<
details
::
async_log_helper
>
_async_log_helper
;
...
...
include/spdlog/common.h
View file @
5d5f2f3a
...
...
@@ -106,6 +106,15 @@ enum class async_overflow_policy
discard_log_msg
// Discard the message it enqueue fails
};
//
// Pattern time - specific time getting to use for pattern_formatter.
// local time by default
//
enum
class
pattern_time_type
{
local
,
// use variant of time similar to std::localtime for std::tm
utc
// use variant of time similar to std::gmtime for std::tm
};
//
// Log exception
...
...
include/spdlog/details/async_logger_impl.h
View file @
5d5f2f3a
...
...
@@ -76,9 +76,9 @@ inline void spdlog::async_logger::_set_formatter(spdlog::formatter_ptr msg_forma
_async_log_helper
->
set_formatter
(
_formatter
);
}
inline
void
spdlog
::
async_logger
::
_set_pattern
(
const
std
::
string
&
pattern
)
inline
void
spdlog
::
async_logger
::
_set_pattern
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
)
{
_formatter
=
std
::
make_shared
<
pattern_formatter
>
(
pattern
);
_formatter
=
std
::
make_shared
<
pattern_formatter
>
(
pattern
,
pattern_time
);
_async_log_helper
->
set_formatter
(
_formatter
);
}
...
...
include/spdlog/details/logger_impl.h
View file @
5d5f2f3a
...
...
@@ -53,9 +53,9 @@ inline void spdlog::logger::set_formatter(spdlog::formatter_ptr msg_formatter)
_set_formatter
(
msg_formatter
);
}
inline
void
spdlog
::
logger
::
set_pattern
(
const
std
::
string
&
pattern
)
inline
void
spdlog
::
logger
::
set_pattern
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
)
{
_set_pattern
(
pattern
);
_set_pattern
(
pattern
,
pattern_time
);
}
...
...
@@ -316,9 +316,9 @@ inline void spdlog::logger::_sink_it(details::log_msg& msg)
flush
();
}
inline
void
spdlog
::
logger
::
_set_pattern
(
const
std
::
string
&
pattern
)
inline
void
spdlog
::
logger
::
_set_pattern
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
)
{
_formatter
=
std
::
make_shared
<
pattern_formatter
>
(
pattern
);
_formatter
=
std
::
make_shared
<
pattern_formatter
>
(
pattern
,
pattern_time
);
}
inline
void
spdlog
::
logger
::
_set_formatter
(
formatter_ptr
msg_formatter
)
{
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
5d5f2f3a
...
...
@@ -324,7 +324,6 @@ class T_formatter SPDLOG_FINAL:public flag_formatter
}
};
// ISO 8601 offset from UTC in timezone (+-HH:MM)
class
z_formatter
SPDLOG_FINAL
:
public
flag_formatter
{
...
...
@@ -495,7 +494,8 @@ class full_formatter SPDLOG_FINAL:public flag_formatter
///////////////////////////////////////////////////////////////////////////////
// pattern_formatter inline impl
///////////////////////////////////////////////////////////////////////////////
inline
spdlog
::
pattern_formatter
::
pattern_formatter
(
const
std
::
string
&
pattern
)
inline
spdlog
::
pattern_formatter
::
pattern_formatter
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
)
:
_pattern_time
(
pattern_time
)
{
compile_pattern
(
pattern
);
}
...
...
@@ -665,12 +665,19 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
}
}
inline
std
::
tm
spdlog
::
pattern_formatter
::
get_time
(
details
::
log_msg
&
msg
)
{
if
(
_pattern_time
==
pattern_time_type
::
local
)
return
details
::
os
::
localtime
(
log_clock
::
to_time_t
(
msg
.
time
));
else
return
details
::
os
::
gmtime
(
log_clock
::
to_time_t
(
msg
.
time
));
}
inline
void
spdlog
::
pattern_formatter
::
format
(
details
::
log_msg
&
msg
)
{
#ifndef SPDLOG_NO_DATETIME
auto
tm_time
=
details
::
os
::
localtime
(
log_clock
::
to_time_t
(
msg
.
time
)
);
auto
tm_time
=
get_time
(
msg
);
#else
std
::
tm
tm_time
;
#endif
...
...
include/spdlog/formatter.h
View file @
5d5f2f3a
...
...
@@ -29,13 +29,15 @@ class pattern_formatter SPDLOG_FINAL : public formatter
{
public:
explicit
pattern_formatter
(
const
std
::
string
&
pattern
);
explicit
pattern_formatter
(
const
std
::
string
&
pattern
,
pattern_time_type
pattern_time
=
pattern_time_type
::
local
);
pattern_formatter
(
const
pattern_formatter
&
)
=
delete
;
pattern_formatter
&
operator
=
(
const
pattern_formatter
&
)
=
delete
;
void
format
(
details
::
log_msg
&
msg
)
override
;
private:
const
std
::
string
_pattern
;
const
pattern_time_type
_pattern_time
;
std
::
vector
<
std
::
unique_ptr
<
details
::
flag_formatter
>>
_formatters
;
std
::
tm
get_time
(
details
::
log_msg
&
msg
);
void
handle_flag
(
char
flag
);
void
compile_pattern
(
const
std
::
string
&
pattern
);
};
...
...
include/spdlog/logger.h
View file @
5d5f2f3a
...
...
@@ -66,7 +66,7 @@ public:
void
set_level
(
level
::
level_enum
);
level
::
level_enum
level
()
const
;
const
std
::
string
&
name
()
const
;
void
set_pattern
(
const
std
::
string
&
);
void
set_pattern
(
const
std
::
string
&
,
pattern_time_type
=
pattern_time_type
::
local
);
void
set_formatter
(
formatter_ptr
);
// automatically call flush() if message level >= log_level
...
...
@@ -82,7 +82,7 @@ public:
protected:
virtual
void
_sink_it
(
details
::
log_msg
&
);
virtual
void
_set_pattern
(
const
std
::
string
&
);
virtual
void
_set_pattern
(
const
std
::
string
&
,
pattern_time_type
);
virtual
void
_set_formatter
(
formatter_ptr
);
// default error handler: print the error to stderr with the max rate of 1 message/minute
...
...
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