Commit Graph

27 Commits

Author SHA1 Message Date
Omar Polo
a81dd6cda6 fix "double slash" in logs
gmid ended up printing two slashes between the hostname and the path
when logging the request IRI.
2021-10-24 16:34:30 +00:00
Omar Polo
387b976b99 c->req may be NULL now 2021-10-15 07:51:15 +00:00
Omar Polo
d0071d8321 verbose logging for getnameinfo 2021-10-02 17:20:56 +00:00
Omar Polo
db623d7551 fix syslog logging on FreeBSD
Due to capsicum(4), opening the log on-demand via syslog(3) fails.
openlog(LOG_NDELAY) forces the log to be opened immediately, before we
enter capsicum.

This doesn't affect OpenBSD (where pledge(2) doesn't stop syslog) nor
linux (where the log process is not sandboxed.)

Reported by Karl Jeacle, thank you!
2021-09-17 16:17:16 +00:00
Omar Polo
ef352ec3b8 fix wrong arguments order for send_log 2021-08-23 22:36:01 +00:00
Omar Polo
41395640e0 introduce IMSG_LOG_REQUEST 2021-07-19 07:31:40 +00:00
Omar Polo
2b5e2a5f04 send_log: accept explicit imsg type param 2021-07-19 07:23:38 +00:00
Omar Polo
8a50fc0330 initialize the logger early
Initialize the logger as soon as possible and log by default to
stderr.  With this, some (common?) errors are printed early instead of
ending up in syslog.

	# NB: this is in configless mode
	% ./gmid -p 80
	[2021-07-07 11:05:57] bind: Address already in use
	% ./gmid -p 81
	[2021-07-07 11:13:53] bind: Permission denied
	%
2021-07-07 09:18:24 +00:00
Omar Polo
7700ab07d3 fmt 2021-07-06 10:56:13 +00:00
Omar Polo
984c46a82e kill unused variable
leftover from the handle_imsg_log -> do_log transition.
2021-06-16 14:38:47 +00:00
Omar Polo
e952c5052a allow sending fd to log on to the logger process
the logger process now can receive a file descriptor to write logs
to.  At the moment the logic is simple, if it receives a file it logs
there, otherwise it logs to syslog.  This will allow to log on custom
log files.
2021-06-15 08:06:10 +00:00
Omar Polo
2ef7f631db wait for logger after fatal()
With -f, when the main process exits after a fatal() (usually) the
shell prompt is printed before the logger message.

This adds a small poll to wait for the logger process to exit.
2021-04-28 12:43:17 +00:00
Omar Polo
d89a9060f8 fatal: send log to logger 2021-04-28 12:43:17 +00:00
Omar Polo
42447f673f send priority to the logger process 2021-04-28 12:43:17 +00:00
Omar Polo
e6ca8eb156 lower log priority for fatal errors from CRIT to ERR
found by Anna, thanks!
2021-04-28 12:43:17 +00:00
Omar Polo
b33425827e print the datetime when logging to stderr 2021-04-14 14:52:47 +00:00
Omar Polo
62e001b067 move all sandbox-related code to sandbox.c
while there, add capsicum for the logger process
2021-03-20 08:42:08 +00:00
Omar Polo
bc99d868bc refactoring: imsg everywhere
use imsg to handle ALL kinds of IPC in gmid.  This simplifies and shorten the
code, and  makes everything more uniform too.
2021-03-19 19:21:29 +00:00
Omar Polo
de62c38d81 fix out-of-bounds access
obviously msg[datalen] is an off-by-one
2021-03-03 17:51:30 +00:00
Omar Polo
376a540764
move log_init & vars to gmid.c, retain logger_main in log.c
this is to let the regression suite compile
2021-02-23 13:44:20 +01:00
Omar Polo
4604dc9671
move vhost_should_log call to server.c
log.o is linked to some regress/ stuff.  Calling from there a vhost_*
function means that we should link the regress/stuff to server.o too
(and that would pull in other stuff...).  Moving the call is easier,
and also probably better.
2021-02-23 13:43:33 +01:00
Omar Polo
793835cb26
add `log on/off' to enable/disable logs per-location 2021-02-23 13:43:24 +01:00
Omar Polo
fd9a486925
don't directly include sys/queue.h 2021-02-23 13:43:23 +01:00
Omar Polo
6b191ed52a
tests and compat for imsg 2021-02-23 13:43:14 +01:00
Omar Polo
d278a0c3c5
moving logging to its own process 2021-02-23 13:40:59 +01:00
Omar Polo
52418c8d82 fix various compilation errors
Include gmid.h as first header in every file, as it then includes
config.h (that defines _GNU_SOURCE for instance).

Fix also a warning about unsigned vs signed const char pointers in
openssl.
2021-02-12 12:47:20 +00:00
Omar Polo
7e9b7812b3 move logging code to log.c 2021-02-07 16:15:51 +00:00