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
a067eb02
Commit
a067eb02
authored
Nov 06, 2014
by
Lucas Pardue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LOG_NOTICE level logging for application lifecycle events
parent
03a2828f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
40 deletions
+49
-40
src/shrpx.cc
src/shrpx.cc
+8
-18
src/shrpx_log.cc
src/shrpx_log.cc
+35
-16
src/shrpx_log.h
src/shrpx_log.h
+1
-1
src/shrpx_ssl.cc
src/shrpx_ssl.cc
+4
-2
src/shrpx_thread_event_receiver.cc
src/shrpx_thread_event_receiver.cc
+1
-3
No files found.
src/shrpx.cc
View file @
a067eb02
...
...
@@ -190,9 +190,7 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
// Otherwise, close fd, and create server socket as usual.
if
(
port
==
get_config
()
->
port
)
{
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Listening on port "
<<
get_config
()
->
port
;
}
LOG
(
NOTICE
)
<<
"Listening on port "
<<
get_config
()
->
port
;
return
new_evlistener
(
handler
,
fd
);
}
...
...
@@ -279,9 +277,7 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
return
nullptr
;
}
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Listening on "
<<
host
<<
", port "
<<
get_config
()
->
port
;
}
LOG
(
NOTICE
)
<<
"Listening on "
<<
host
<<
", port "
<<
get_config
()
->
port
;
return
new_evlistener
(
handler
,
fd
);
}
...
...
@@ -356,9 +352,7 @@ void exec_binary_signal_cb(evutil_socket_t sig, short events, void *arg)
{
auto
listener_handler
=
static_cast
<
ListenHandler
*>
(
arg
);
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Executing new binary"
;
}
LOG
(
NOTICE
)
<<
"Executing new binary"
;
auto
pid
=
fork
();
...
...
@@ -449,9 +443,7 @@ void graceful_shutdown_signal_cb(evutil_socket_t sig, short events, void *arg)
{
auto
listener_handler
=
static_cast
<
ListenHandler
*>
(
arg
);
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Graceful shutdown signal received"
;
}
LOG
(
NOTICE
)
<<
"Graceful shutdown signal received"
;
worker_config
->
graceful_shutdown
=
true
;
...
...
@@ -1132,8 +1124,8 @@ Mode:
Logging:
-L, --log-level=<LEVEL>
Set the severity level of log output. <LEVEL>
must be one of INFO, WARNING, ERROR and FATAL.
Default:
WARNING
must be one of INFO,
NOTICE,
WARNING, ERROR and FATAL.
Default:
NOTICE
--accesslog-file=<PATH>
Set path to write access log. To reopen file,
send USR1 signal to nghttpx.
...
...
@@ -1216,7 +1208,7 @@ Misc:
int
main
(
int
argc
,
char
**
argv
)
{
Log
::
set_severity_level
(
WARNING
);
Log
::
set_severity_level
(
NOTICE
);
create_config
();
fill_default_config
();
...
...
@@ -1887,9 +1879,7 @@ int main(int argc, char **argv)
event_loop
();
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Shutdown momentarily"
;
}
LOG
(
NOTICE
)
<<
"Shutdown momentarily"
;
return
0
;
}
...
...
src/shrpx_log.cc
View file @
a067eb02
...
...
@@ -45,20 +45,21 @@ namespace shrpx {
namespace
{
const
char
*
SEVERITY_STR
[]
=
{
"INFO"
,
"WARN"
,
"ERROR"
,
"FATAL"
"INFO"
,
"
NOTICE"
,
"
WARN"
,
"ERROR"
,
"FATAL"
};
}
// namespace
namespace
{
const
char
*
SEVERITY_COLOR
[]
=
{
"
\033
[1;32m"
,
// INFO
"
\033
[1;36m"
,
// NOTICE
"
\033
[1;33m"
,
// WARN
"
\033
[1;31m"
,
// ERROR
"
\033
[1;35m"
,
// FATAL
};
}
// namespace
int
Log
::
severity_thres_
=
WARNING
;
int
Log
::
severity_thres_
=
NOTICE
;
void
Log
::
set_severity_level
(
int
severity
)
{
...
...
@@ -81,6 +82,8 @@ int severity_to_syslog_level(int severity)
switch
(
severity
)
{
case
(
INFO
):
return
LOG_INFO
;
case
(
NOTICE
):
return
LOG_NOTICE
;
case
(
WARNING
):
return
LOG_WARNING
;
case
(
ERROR
):
...
...
@@ -110,9 +113,14 @@ Log::~Log()
}
if
(
get_config
()
->
errorlog_syslog
)
{
syslog
(
severity_to_syslog_level
(
severity_
),
"[%s] %s (%s:%d)"
,
SEVERITY_STR
[
severity_
],
stream_
.
str
().
c_str
(),
filename_
,
linenum_
);
if
(
severity_
==
NOTICE
)
{
syslog
(
severity_to_syslog_level
(
severity_
),
"[%s] %s"
,
SEVERITY_STR
[
severity_
],
stream_
.
str
().
c_str
());
}
else
{
syslog
(
severity_to_syslog_level
(
severity_
),
"[%s] %s (%s:%d)"
,
SEVERITY_STR
[
severity_
],
stream_
.
str
().
c_str
(),
filename_
,
linenum_
);
}
return
;
}
...
...
@@ -122,17 +130,28 @@ Log::~Log()
auto
cached_time
=
get_config
()
->
cached_time
;
rv
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s PID%d [%s%s%s] %s%s:%d%s %s
\n
"
,
cached_time
->
c_str
(),
getpid
(),
tty
?
SEVERITY_COLOR
[
severity_
]
:
""
,
SEVERITY_STR
[
severity_
],
tty
?
"
\033
[0m"
:
""
,
tty
?
"
\033
[1;30m"
:
""
,
filename_
,
linenum_
,
tty
?
"
\033
[0m"
:
""
,
stream_
.
str
().
c_str
());
if
(
severity_
==
NOTICE
)
{
rv
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s PID%d [%s%s%s] %s
\n
"
,
cached_time
->
c_str
(),
getpid
(),
tty
?
SEVERITY_COLOR
[
severity_
]
:
""
,
SEVERITY_STR
[
severity_
],
tty
?
"
\033
[0m"
:
""
,
stream_
.
str
().
c_str
());
}
else
{
rv
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s PID%d [%s%s%s] %s%s:%d%s %s
\n
"
,
cached_time
->
c_str
(),
getpid
(),
tty
?
SEVERITY_COLOR
[
severity_
]
:
""
,
SEVERITY_STR
[
severity_
],
tty
?
"
\033
[0m"
:
""
,
tty
?
"
\033
[1;30m"
:
""
,
filename_
,
linenum_
,
tty
?
"
\033
[0m"
:
""
,
stream_
.
str
().
c_str
());
}
if
(
rv
<
0
)
{
return
;
...
...
src/shrpx_log.h
View file @
a067eb02
...
...
@@ -71,7 +71,7 @@ class Downstream;
(Log(SEVERITY, __FILE__, __LINE__) << "[DHTTP2:" << HTTP2 << "] ")
enum
SeverityLevel
{
INFO
,
WARNING
,
ERROR
,
FATAL
INFO
,
NOTICE
,
WARNING
,
ERROR
,
FATAL
};
class
Log
{
...
...
src/shrpx_ssl.cc
View file @
a067eb02
...
...
@@ -943,8 +943,10 @@ bool check_http2_requirement(SSL *ssl)
case
TLS1_2_VERSION
:
break
;
default:
LOG
(
INFO
)
<<
"TLSv1.2 was not negotiated. "
<<
"HTTP/2 must not be negotiated."
;
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"TLSv1.2 was not negotiated. "
<<
"HTTP/2 must not be negotiated."
;
}
return
false
;
}
...
...
src/shrpx_thread_event_receiver.cc
View file @
a067eb02
...
...
@@ -84,9 +84,7 @@ void ThreadEventReceiver::on_read(bufferevent *bev)
}
if
(
wev
.
type
==
GRACEFUL_SHUTDOWN
)
{
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Graceful shutdown commencing"
;
}
LOG
(
NOTICE
)
<<
"Graceful shutdown commencing"
;
worker_config
->
graceful_shutdown
=
true
;
...
...
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