Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
trackrdrd
Commits
02e288a2
Commit
02e288a2
authored
Jun 01, 2014
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MQ plugin for Kafka: signal USR2 toggles debug level logging
parent
363522d7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
2 deletions
+60
-2
README.rst
trackrdrd/src/mq/kafka/README.rst
+17
-1
mq.c
trackrdrd/src/mq/kafka/mq.c
+43
-1
No files found.
trackrdrd/src/mq/kafka/README.rst
View file @
02e288a2
...
@@ -243,6 +243,9 @@ Statistic Description
...
@@ -243,6 +243,9 @@ Statistic Description
payload.
payload.
===================== ==========================================================
===================== ==========================================================
The log level can be toggled to DEBUG and back by sending signal
``USR2`` to the process, as described below.
MESSAGE SEND FAILURE AND RECOVERY
MESSAGE SEND FAILURE AND RECOVERY
=================================
=================================
...
@@ -278,7 +281,20 @@ point in time.
...
@@ -278,7 +281,20 @@ point in time.
SIGNALS
SIGNALS
=======
=======
XXX: TuDu -- toggle DEBUG log level
The message plugin overrides the signal handler of the tracking
reader's child process for signal ``USR2`` (see signal(7)), so that it
toggles the DEBUG log level when the process receives the signal.
The initial log level is set by the configuration parameter
``mq.debug`` when the plugin is initialized, and the level is changed
from this level to DEBUG, or from DEBUG back to the initial level,
when ``USR2`` is sent to the process (for example by using
kill(1)). Log level toggling affects logging for the messaging plugin
as well as the rdkafka and zookeeper client libraries.
Logging at DEBUG level may be very verbose, so that log files may
become very large (and partitions may overflow) if DEBUG level is left
on for a long time.
SEE ALSO
SEE ALSO
========
========
...
...
trackrdrd/src/mq/kafka/mq.c
View file @
02e288a2
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include <limits.h>
#include <limits.h>
#include <syslog.h>
#include <syslog.h>
#include <ctype.h>
#include <ctype.h>
#include <signal.h>
#include <zookeeper/zookeeper.h>
#include <zookeeper/zookeeper.h>
#include <zookeeper/zookeeper_version.h>
#include <zookeeper/zookeeper_version.h>
...
@@ -75,11 +76,42 @@ static char topic[LINE_MAX] = "";
...
@@ -75,11 +76,42 @@ static char topic[LINE_MAX] = "";
static
rd_kafka_topic_conf_t
*
topic_conf
;
static
rd_kafka_topic_conf_t
*
topic_conf
;
static
rd_kafka_conf_t
*
conf
;
static
rd_kafka_conf_t
*
conf
;
static
unsigned
stats_interval
=
0
;
static
char
errmsg
[
LINE_MAX
];
static
char
errmsg
[
LINE_MAX
];
static
char
_version
[
LINE_MAX
];
static
char
_version
[
LINE_MAX
];
static
int
loglvl
=
LOG_INFO
;
static
int
loglvl
=
LOG_INFO
;
static
unsigned
stats_interval
=
0
;
static
int
saved_lvl
=
LOG_INFO
;
static
int
debug_toggle
=
0
;
struct
sigaction
toggle_action
;
static
void
toggle_debug
(
int
sig
)
{
(
void
)
sig
;
if
(
debug_toggle
)
{
/* Toggle from debug back to saved level */
loglvl
=
saved_lvl
;
debug_toggle
=
0
;
MQ_LOG_Log
(
LOG_INFO
,
"Debug toggle switched off"
);
zoo_set_debug_level
(
ZOO_LOG_LEVEL_INFO
);
}
else
{
saved_lvl
=
loglvl
;
loglvl
=
LOG_DEBUG
;
debug_toggle
=
1
;
MQ_LOG_Log
(
LOG_INFO
,
"Debug toggle switched on"
);
zoo_set_debug_level
(
ZOO_LOG_LEVEL_DEBUG
);
}
MQ_LOG_SetLevel
(
loglvl
);
for
(
int
i
=
0
;
i
<
nwrk
;
i
++
)
if
(
workers
[
i
]
!=
NULL
)
{
CHECK_OBJ
(
workers
[
i
],
KAFKA_WRK_MAGIC
);
rd_kafka_set_log_level
(
workers
[
i
]
->
kafka
,
loglvl
);
}
}
static
void
static
void
log_cb
(
const
rd_kafka_t
*
rk
,
int
level
,
const
char
*
fac
,
const
char
*
buf
)
log_cb
(
const
rd_kafka_t
*
rk
,
int
level
,
const
char
*
fac
,
const
char
*
buf
)
...
@@ -397,6 +429,16 @@ MQ_GlobalInit(unsigned nworkers, const char *config_fname)
...
@@ -397,6 +429,16 @@ MQ_GlobalInit(unsigned nworkers, const char *config_fname)
return
errmsg
;
return
errmsg
;
}
}
toggle_action
.
sa_handler
=
toggle_debug
;
AZ
(
sigemptyset
(
&
toggle_action
.
sa_mask
));
toggle_action
.
sa_flags
|=
SA_RESTART
;
if
(
sigaction
(
SIGUSR2
,
&
toggle_action
,
NULL
)
!=
0
)
{
snprintf
(
errmsg
,
LINE_MAX
,
"Cannot install signal handler for USR2: %s"
,
strerror
(
errno
));
MQ_LOG_Log
(
LOG_ERR
,
errmsg
);
return
errmsg
;
}
if
(
zoolog
[
0
]
!=
'\0'
)
{
if
(
zoolog
[
0
]
!=
'\0'
)
{
zoologf
=
fopen
(
zoolog
,
"a"
);
zoologf
=
fopen
(
zoolog
,
"a"
);
if
(
zoologf
==
NULL
)
{
if
(
zoologf
==
NULL
)
{
...
...
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