Skip to content

Commit

Permalink
add log_level conf var
Browse files Browse the repository at this point in the history
  • Loading branch information
tony2001 committed Jun 27, 2016
1 parent 29e65e1 commit aa012b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ha_pinba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static int cpu_start_var = 0;
static int histogram_max_time_var = 0;
static int histogram_size_var = 0;
static int data_job_size_var = 0;
static unsigned int log_level_var = P_ERROR | P_WARNING | P_NOTICE;

/* global daemon struct, created once per process and used everywhere */
pinba_daemon *D;
Expand Down Expand Up @@ -589,6 +590,7 @@ static int pinba_engine_init(void *p) /* {{{ */
settings.timer_pool_size = timer_pool_size_var < PINBA_TIMER_POOL_GROW_SIZE ? PINBA_TIMER_POOL_GROW_SIZE : timer_pool_size_var;
settings.data_job_size = data_job_size_var;
settings.histogram_size = histogram_size_var;
settings.log_level = log_level_var;

/* default value of temp_pool_size_limit is temp_pool_size * 10 */
if (!temp_pool_size_limit_var || temp_pool_size_limit_var < temp_pool_size_var) {
Expand Down Expand Up @@ -8763,6 +8765,18 @@ static MYSQL_SYSVAR_INT(data_job_size,
INT_MAX,
0);

static MYSQL_SYSVAR_UINT(log_level,
log_level_var,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Set log level",
NULL,
NULL,
P_ERROR | P_WARNING | P_NOTICE,
0,
INT_MAX,
0);


static struct st_mysql_sys_var* system_variables[]= {
MYSQL_SYSVAR(port),
MYSQL_SYSVAR(address),
Expand All @@ -8777,6 +8791,7 @@ static struct st_mysql_sys_var* system_variables[]= {
MYSQL_SYSVAR(histogram_max_time),
MYSQL_SYSVAR(histogram_size),
MYSQL_SYSVAR(data_job_size),
MYSQL_SYSVAR(log_level),
NULL
};
/* }}} */
Expand Down
4 changes: 4 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,10 @@ char *pinba_error_ex(int return_error, int type, const char *file, int line, con
char tmp_format[PINBA_ERR_BUFFER/2];
char errormsg[PINBA_ERR_BUFFER];

if ((D->settings.log_level & type) == 0) {
return NULL;
}

switch (type) {
case P_DEBUG_DUMP:
type_name = "debug dump";
Expand Down
1 change: 1 addition & 0 deletions src/pinba_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ typedef struct _pinba_daemon_settings { /* {{{ */
int cpu_start;
size_t data_job_size;
size_t histogram_size;
unsigned int log_level;
} pinba_daemon_settings;
/* }}} */

Expand Down

0 comments on commit aa012b7

Please sign in to comment.