Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
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
nghttp2
Commits
1fe50f27
Commit
1fe50f27
authored
Nov 24, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add $pid to --accesslog-format variable
$pid refers to the PID of the running process.
parent
93023acc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
4 deletions
+18
-4
src/shrpx.cc
src/shrpx.cc
+2
-0
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+4
-2
src/shrpx_config.cc
src/shrpx_config.cc
+2
-0
src/shrpx_config.h
src/shrpx_config.h
+1
-0
src/shrpx_log.cc
src/shrpx_log.cc
+5
-2
src/shrpx_log.h
src/shrpx_log.h
+4
-0
No files found.
src/shrpx.cc
View file @
1fe50f27
...
...
@@ -759,6 +759,7 @@ void fill_default_config()
mod_config
()
->
pid_file
=
nullptr
;
mod_config
()
->
uid
=
0
;
mod_config
()
->
gid
=
0
;
mod_config
()
->
pid
=
getpid
();
mod_config
()
->
backend_ipv4
=
false
;
mod_config
()
->
backend_ipv6
=
false
;
mod_config
()
->
cert_tree
=
nullptr
;
...
...
@@ -1142,6 +1143,7 @@ Logging:
$server_port: server port.
$request_time: request processing time in
seconds with milliseconds resolution.
$pid: PID of the running process.
Default: )"
<<
DEFAULT_ACCESSLOG_FORMAT
<<
R"(
--errorlog-file=<PATH>
...
...
src/shrpx_client_handler.cc
View file @
1fe50f27
...
...
@@ -746,7 +746,8 @@ void ClientHandler::write_accesslog(Downstream *downstream)
downstream
->
get_response_http_status
(),
downstream
->
get_response_sent_bodylen
(),
port_
.
c_str
(),
get_config
()
->
port
get_config
()
->
port
,
get_config
()
->
pid
,
};
upstream_accesslog
(
get_config
()
->
accesslog_format
,
&
lgsp
);
...
...
@@ -767,7 +768,8 @@ void ClientHandler::write_accesslog(int major, int minor,
status
,
body_bytes_sent
,
port_
.
c_str
(),
get_config
()
->
port
get_config
()
->
port
,
get_config
()
->
pid
,
};
upstream_accesslog
(
get_config
()
->
accesslog_format
,
&
lgsp
);
...
...
src/shrpx_config.cc
View file @
1fe50f27
...
...
@@ -402,6 +402,8 @@ std::vector<LogFragment> parse_log_format(const char *optarg)
type
=
SHRPX_LOGF_SERVER_PORT
;
}
else
if
(
util
::
strieq
(
"$request_time"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_REQUEST_TIME
;
}
else
if
(
util
::
strieq
(
"$pid"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_PID
;
}
else
{
LOG
(
WARN
)
<<
"Unrecognized log format variable: "
<<
std
::
string
(
var_start
,
varlen
);
...
...
src/shrpx_config.h
View file @
1fe50f27
...
...
@@ -254,6 +254,7 @@ struct Config {
int
argc
;
uid_t
uid
;
gid_t
gid
;
pid_t
pid
;
uint16_t
port
;
uint16_t
downstream_port
;
// port in http proxy URI
...
...
src/shrpx_log.cc
View file @
1fe50f27
...
...
@@ -139,7 +139,7 @@ Log::~Log()
rv
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s PID%d [%s%s%s] %s
\n
"
,
cached_time
->
c_str
(),
get
pid
()
,
get
_config
()
->
pid
,
tty
?
SEVERITY_COLOR
[
severity_
]
:
""
,
SEVERITY_STR
[
severity_
],
tty
?
"
\033
[0m"
:
""
,
...
...
@@ -148,7 +148,7 @@ Log::~Log()
rv
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s PID%d [%s%s%s] %s%s:%d%s %s
\n
"
,
cached_time
->
c_str
(),
get
pid
()
,
get
_config
()
->
pid
,
tty
?
SEVERITY_COLOR
[
severity_
]
:
""
,
SEVERITY_STR
[
severity_
],
tty
?
"
\033
[0m"
:
""
,
...
...
@@ -258,6 +258,9 @@ void upstream_accesslog(const std::vector<LogFragment>& lfv, LogSpec *lgsp)
std
::
tie
(
p
,
avail
)
=
copy
(
sec
.
c_str
(),
avail
,
p
);
}
break
;
case
SHRPX_LOGF_PID
:
std
::
tie
(
p
,
avail
)
=
copy
(
util
::
utos
(
lgsp
->
pid
).
c_str
(),
avail
,
p
);
break
;
case
SHRPX_LOGF_NONE
:
break
;
default:
...
...
src/shrpx_log.h
View file @
1fe50f27
...
...
@@ -27,6 +27,8 @@
#include "shrpx.h"
#include <sys/types.h>
#include <sstream>
#include <memory>
#include <vector>
...
...
@@ -116,6 +118,7 @@ enum LogFragmentType {
SHRPX_LOGF_REMOTE_PORT
,
SHRPX_LOGF_SERVER_PORT
,
SHRPX_LOGF_REQUEST_TIME
,
SHRPX_LOGF_PID
,
};
struct
LogFragment
{
...
...
@@ -135,6 +138,7 @@ struct LogSpec {
int64_t
body_bytes_sent
;
const
char
*
remote_port
;
uint16_t
server_port
;
pid_t
pid
;
};
void
upstream_accesslog
(
const
std
::
vector
<
LogFragment
>&
lf
,
LogSpec
*
lgsp
);
...
...
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