mirror of
https://github.com/emqx/neuron.git
synced 2026-10-29 07:06:32 +08:00
feat:core subscription supports filtering error messages
This commit is contained in:
@@ -80,6 +80,7 @@ const char *usage_text =
|
||||
" --plugin_dir <DIR> directory from which neuron loads plugin lib files\n"
|
||||
" --syslog_host <HOST> syslog server host to which neuron will send logs\n"
|
||||
" --syslog_port <PORT> syslog server port (default 541 if not provided)\n"
|
||||
" --sub_filter_error The subscribe attribute only detects the last read value and does not report any error tags\n"
|
||||
"\n";
|
||||
// clang-format on
|
||||
|
||||
@@ -181,6 +182,19 @@ static inline int load_env(neu_cli_args_t *args, char **log_level_out,
|
||||
}
|
||||
}
|
||||
|
||||
char *sub_filter_e = getenv(NEU_ENV_SUB_FILTER_ERROR);
|
||||
if (sub_filter_e != NULL) {
|
||||
if (strcmp(sub_filter_e, "1") == 0) {
|
||||
args->sub_filter_err = true;
|
||||
} else if (strcmp(sub_filter_e, "0") == 0) {
|
||||
args->sub_filter_err = false;
|
||||
} else {
|
||||
printf("neuron NEURON_SUB_FILTER_ERROR setting error!\n");
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char *log_level = getenv(NEU_ENV_LOG_LEVEL);
|
||||
if (log_level != NULL) {
|
||||
if (*log_level_out != NULL) {
|
||||
@@ -289,6 +303,7 @@ static inline int load_config_file(int argc, char *argv[],
|
||||
{ .name = "port", .t = NEU_JSON_INT },
|
||||
{ .name = "syslog_host", .t = NEU_JSON_STR },
|
||||
{ .name = "syslog_port", .t = NEU_JSON_INT },
|
||||
{ .name = "sub_filter_error", .t = NEU_JSON_INT },
|
||||
};
|
||||
|
||||
resolve_config_file_path(argc, argv, long_options, opts, &config_file);
|
||||
@@ -369,6 +384,16 @@ static inline int load_config_file(int argc, char *argv[],
|
||||
break;
|
||||
}
|
||||
|
||||
if (elems[5].v.val_int == 1) {
|
||||
args->sub_filter_err = true;
|
||||
} else if (elems[5].v.val_int == 0) {
|
||||
args->sub_filter_err = false;
|
||||
} else {
|
||||
printf("config file %s sub_filter_error setting error!\n",
|
||||
config_file);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
} else {
|
||||
printf("config file %s elems error! must had ip, port and "
|
||||
@@ -424,6 +449,7 @@ void neu_cli_args_init(neu_cli_args_t *args, int argc, char *argv[])
|
||||
{ "stop", no_argument, NULL, 's' },
|
||||
{ "syslog_host", required_argument, NULL, 'S' },
|
||||
{ "syslog_port", required_argument, NULL, 'P' },
|
||||
{ "sub_filter_error", no_argument, NULL, 'f' },
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
|
||||
@@ -517,6 +543,9 @@ void neu_cli_args_init(neu_cli_args_t *args, int argc, char *argv[])
|
||||
}
|
||||
args->syslog_host = strdup(optarg);
|
||||
break;
|
||||
case 'f':
|
||||
args->sub_filter_err = true;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
|
||||
Reference in New Issue
Block a user