From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Olga Arkhangelskaia <arkholga@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] [PATCH v5 1/4] Configurable syslog destination
Date: Wed, 1 Aug 2018 15:45:48 +0300 [thread overview]
Message-ID: <20180801124548.zx6ycuvrczdo5oh6@esperanza> (raw)
In-Reply-To: <20180731171519.74073-2-arkholga@tarantool.org>
On Tue, Jul 31, 2018 at 08:15:16PM +0300, Olga Arkhangelskaia wrote:
> Added server option to syslog configuration.
> Server option is responsible for log destination. At the momemt
> there is two ways of usage:server=unix:/path/to/socket or
> server=ipv4:port. If port is not set default udp port 514 is used.
> If logging to syslog is set, however there is no sever options -
> default location is used: Linux /dev/log and Mac /var/run/syslog.
>
> Closes #3487
> ---
> src/say.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
> src/say.h | 15 ++++++++-
> 2 files changed, 115 insertions(+), 6 deletions(-)
We don't submit tests in separate patches. Please squash the tests in
this patch.
> +static int
> +syslog_connect_remote(const char *server_address)
> +{
> + struct addrinfo *inf, hints, *ptr;
> + const char *remote;
> + char buf[10];
> + char *portnum, *copy;
> + int fd = -1;
> + int ret;
> +
> + copy = strdup(server_address);
> + if (copy == NULL) {
> + diag_set(OutOfMemory, strlen(server_address), "malloc",
> + "stslog server address");
> + return fd;
> + }
> + portnum = copy;
> + remote = strsep(&portnum, ":");
> + if (portnum == NULL) {
> + snprintf(buf, sizeof(buf), "%d", SAY_SYSLOG_DEFAULT_PORT);
> + portnum = buf;
> + }
> + memset(&hints, 0, sizeof(hints));
> + hints.ai_family = AF_INET;
> + hints.ai_socktype = SOCK_DGRAM;
> + hints.ai_protocol = IPPROTO_UDP;
> +
> + ret = getaddrinfo(remote, (const char*)portnum, NULL, &inf);
> + if (ret < 0) {
> + errno = EIO;
> + diag_set(SystemError, "getaddrinfo %s",
> + gai_strerror(ret));
Add a colon (':') between "getaddrinfo" and "%s" please.
> + goto out;
> + }
> + for (ptr = inf; ptr; ptr = ptr->ai_next) {
> + fd = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
> + if (fd < 0) {
> + diag_set(SystemError, "socket %s",
> + strerror(errno));
You don't need to append strerror(errno) to the error message.
SystemError will do it for you anyway. So you can simply write
diag_set(SystemError, "socket");
> + continue;
> + }
> + if (connect(fd, inf->ai_addr, inf->ai_addrlen) != 0) {
> + close(fd);
> + fd = -1;
> + diag_set(SystemError, "connect %s",
> + strerror(errno));
Ditto.
> @@ -141,7 +147,12 @@ struct log {
> /** The current log level. */
> int level;
> enum say_logger_type type;
> - /** path to file if logging to file. */
> + /* Type of syslog destination. */
> + enum say_syslog_server_type syslog_server_type;
> + /**
> + * Path to file if logging to file, socket
> + * or server address in case of syslog.
^^
Malformed comment formatting. An extra space between '*' and 'or'.
Please remove.
> + */
> char *path;
> bool nonblock;
> log_format_func_t format_func;
next prev parent reply other threads:[~2018-08-01 12:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 17:15 [tarantool-patches] [PATCH v5 0/4] Syslog destination Olga Arkhangelskaia
2018-07-31 17:15 ` [tarantool-patches] [PATCH v5 1/4] Configurable syslog destination Olga Arkhangelskaia
2018-08-01 12:45 ` Vladimir Davydov [this message]
2018-07-31 17:15 ` [tarantool-patches] [PATCH v5 2/4] box-tap: test valid log configuration Olga Arkhangelskaia
2018-08-01 12:52 ` Vladimir Davydov
2018-07-31 17:15 ` [tarantool-patches] [PATCH v5 3/4] box-tap: syslog destination test unix socket Olga Arkhangelskaia
2018-07-31 17:15 ` [tarantool-patches] [PATCH v5 4/4] box-tap:syslog remote destination test Olga Arkhangelskaia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180801124548.zx6ycuvrczdo5oh6@esperanza \
--to=vdavydov.dev@gmail.com \
--cc=arkholga@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH v5 1/4] Configurable syslog destination' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox