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
cf73f02e
Commit
cf73f02e
authored
Dec 02, 2016
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pid support (added the %P option to formatter)
parent
cda27d2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
include/spdlog/details/os.h
include/spdlog/details/os.h
+11
-0
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+16
-1
No files found.
include/spdlog/details/os.h
View file @
cf73f02e
...
@@ -356,6 +356,17 @@ inline std::string errno_str(int err_num)
...
@@ -356,6 +356,17 @@ inline std::string errno_str(int err_num)
#endif
#endif
}
}
inline
int
pid
()
{
#ifdef _WIN32
return
::
_getpid
();
#else
return
static_cast
<
int
>
(
::
getpid
());
#endif
}
}
//os
}
//os
}
//details
}
//details
}
//spdlog
}
//spdlog
include/spdlog/details/pattern_formatter_impl.h
View file @
cf73f02e
...
@@ -356,7 +356,7 @@ private:
...
@@ -356,7 +356,7 @@ private:
//Thread id
//
Thread id
class
t_formatter
:
public
flag_formatter
class
t_formatter
:
public
flag_formatter
{
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
...
@@ -365,6 +365,15 @@ class t_formatter:public flag_formatter
...
@@ -365,6 +365,15 @@ class t_formatter:public flag_formatter
}
}
};
};
// Current pid
class
pid_formatter
:
public
flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
msg
.
formatted
<<
details
::
os
::
pid
();
}
};
class
v_formatter
:
public
flag_formatter
class
v_formatter
:
public
flag_formatter
{
{
...
@@ -453,6 +462,8 @@ class full_formatter:public flag_formatter
...
@@ -453,6 +462,8 @@ class full_formatter:public flag_formatter
}
}
};
};
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
...
@@ -611,6 +622,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
...
@@ -611,6 +622,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
full_formatter
()));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
full_formatter
()));
break
;
break
;
case
(
'P'
):
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
pid_formatter
()));
break
;
default:
//Unkown flag appears as is
default:
//Unkown flag appears as is
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
ch_formatter
(
'%'
)));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
ch_formatter
(
'%'
)));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
ch_formatter
(
flag
)));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
ch_formatter
(
flag
)));
...
...
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