src/shared/parsers.c \
src/shared/queued_entry.c \
src/shared/translate_syslog.c \
- src/libdlog/log_filters.c \
+ src/libdlog/dynamic_config.c \
src/libdlog/loglimiter.c \
src/libdlog/log_pipe.c \
src/libdlog/log_android.c
dlog_logger_conf_radio=dlogutil -b radio -r 256 -n 1 -f /var/log/dlog/radio -v recv_realtime
dlog_logger_conf_kmsg=dlogutil -b kmsg -r 1024 -n 1 -f /var/log/dlog/kernel -v rwtime
util_sorting_buffer_size=8192
-dynamic_filters_path=/tmp/dlog-filters/
+dynamic_config_path=/tmp/dlog-filters/
util_sorting_time_window=5000
util_sorting_buffer_size=32000
-dynamic_filters_path=/tmp/dlog-filters/
+dynamic_config_path=/tmp/dlog-filters/
# A flag indicating if apps/events buffer entries are always checked against static/dynamic limiter rules
limiter_apply_to_all_buffers=0
-# dynamic filters_path - specifies the path to a DIRECTORY to enable dynamic runtime filter set changes (use dlogctl for control)
-# dynamic_filters_path=/run/dlog/filters.d/
+# dynamic config_path - specifies the path to a DIRECTORY to enable dynamic runtime config changes (use dlogctl for control)
+# dynamic_config_path=/run/dlog/filters.d/
##### Settings used by the logging daemon
#include <logconfig.h>
-#define DYNAMIC_FILTERS_CONF_KEY "dynamic_filters_path"
-#define DYNAMIC_FILTERS_FILENAME "FILTERS"
+#define DYNAMIC_CONFIG_CONF_KEY "dynamic_config_path"
+#define DYNAMIC_CONFIG_FILENAME "FILTERS" // legacy name; should ideally become "CONFIG" at some point
-void __dynamic_filters_create(struct log_config *config);
-void __dynamic_filters_destroy();
-void __dynamic_filters_update();
+void __dynamic_config_create(struct log_config *config);
+void __dynamic_config_destroy();
+void __dynamic_config_update();
#ifdef __cplusplus
}
#include <unistd.h>
#include <sys/inotify.h>
+#include <dynamic_config.h>
#include <logcommon.h>
#include <logconfig.h>
-#include <log_filters.h>
#include <loglimiter.h>
static int inotify_fd = -1;
}
/// caller has to guarantee exclusive access
-void __dynamic_filters_create(struct log_config *config)
+void __dynamic_config_create(struct log_config *config)
{
assert(config);
assert(!inotify_path);
- const char *const extra_filters_path = log_config_get(config, DYNAMIC_FILTERS_CONF_KEY);
- if (!extra_filters_path)
+ const char *const extra_config_path = log_config_get(config, DYNAMIC_CONFIG_CONF_KEY);
+ if (!extra_config_path)
return;
- if (asprintf(&inotify_path, "%s/%s", extra_filters_path, DYNAMIC_FILTERS_FILENAME) < 0) {
+ if (asprintf(&inotify_path, "%s/%s", extra_config_path, DYNAMIC_CONFIG_FILENAME) < 0) {
inotify_path = NULL;// LCOV_EXCL_LINE
syslog_critical_failure("DLog: out of memory");// LCOV_EXCL_LINE
return;// LCOV_EXCL_LINE
*/
log_config_read_file(config, inotify_path);
- __setup_runtime_watch(extra_filters_path);
+ __setup_runtime_watch(extra_config_path);
}
/// caller has to guarantee exclusive access
-void __dynamic_filters_destroy()
+void __dynamic_config_destroy()
{
assert(inotify_fd < 0 || inotify_path);
assert(inotify_wd < 0 || inotify_fd >= 0);
inotify_fd = -1;
}
-void __dynamic_filters_update()
+void __dynamic_config_update()
{
if (inotify_fd < 0)
return;
#include <stdbool.h>
#include <stdio.h>
+#include <dynamic_config.h>
#include <logcommon.h>
-#include <log_filters.h>
#include "loglimiter.h"
#include "logconfig.h"
#include <assert.h>
if (!limiter)
return;
- __dynamic_filters_create(config);
+ __dynamic_config_create(config);
limiter = __log_limiter_create(config);
if (!limiter)
- __dynamic_filters_destroy();// LCOV_EXCL_LINE
+ __dynamic_config_destroy(); // LCOV_EXCL_LINE
}
static int __configure_backend(struct log_config *config)
return DLOG_ERROR_NOT_PERMITTED;
if (limiter) {
- __dynamic_filters_update();
+ __dynamic_config_update();
// LCOV_EXCL_START : disabled feature (limiter)
pthread_mutex_lock(&log_init_lock);
void __attribute__((destructor)) __dlog_fini(void)
{
__log_limiter_destroy();
- __dynamic_filters_destroy();
+ __dynamic_config_destroy();
}
#include <sys/stat.h>
// DLog
+#include <dynamic_config.h>
#include <logcommon.h>
#include <logconfig.h>
-#include <log_filters.h>
#include <loglimiter.h>
struct parsed_params {
fprintf(out, "%s%s\n", key, value);
}
-int handle_set(const struct parsed_params *params, char *filters_path, struct log_config *conf)
+int handle_set(const struct parsed_params *params, char *config_path, struct log_config *conf)
{
__attribute__((cleanup(free_ptr))) char *key;
if (asprintf(&key, "limiter|%s|%c=", params->tag, params->prio) < 0) {
return EXIT_FAILURE;
}
- __attribute__((cleanup(close_FILE))) FILE *const filtersfile = fopen(filters_path, "a+"); // won't actually append anything but this is the only mode that both positions the read steam at the beginning and opens the file if missing
- if (!filtersfile) {
- ERR("filters file %s fopen failed: %m\n", filters_path);
+ __attribute__((cleanup(close_FILE))) FILE *const configfile = fopen(config_path, "a+"); // won't actually append anything but this is the only mode that both positions the read steam at the beginning and opens the file if missing
+ if (!configfile) {
+ ERR("config file %s fopen failed: %m\n", config_path);
return EXIT_FAILURE;
}
__attribute__((cleanup(free_ptr))) char *tempname = NULL;
- int r = asprintf(&tempname, "%sXXXXXX", filters_path);
+ int r = asprintf(&tempname, "%sXXXXXX", config_path);
if (r < 0) {
tempname = NULL;
ERR("asprintf tempname failed: %m\n");
goto remove_temp;
}
- copy_except(filtersfile, tempfile, key, params->value);
+ copy_except(configfile, tempfile, key, params->value);
- if (rename(tempname, filters_path) < 0) {
+ if (rename(tempname, config_path) < 0) {
ERR("rename failed: %m\n");
goto remove_temp;
}
*shadowed = true;
}
-int handle_get(const struct parsed_params *params, char *filters_path, struct log_config *conf)
+int handle_get(const struct parsed_params *params, char *config_path, struct log_config *conf)
{
if (!__log_limiter_create(conf)) {
ERR("error creating limiter\n");
struct limiter_limits lims_static = __log_limiter_get_limits(params->tag, params->prio);
- log_config_read_file(conf, filters_path); // not an error on failure - config still valid if missing, static rules apply
+ log_config_read_file(conf, config_path); // not an error on failure - config still valid if missing, static rules apply
__log_limiter_update(conf);
struct limiter_limits lims_dynamic = __log_limiter_get_limits(params->tag, params->prio);
return EXIT_SUCCESS;
}
-int handle_dump(const struct parsed_params *params, char *filters_path, struct log_config *conf)
+int handle_dump(const struct parsed_params *params, char *config_path, struct log_config *conf)
{
if (!__log_limiter_create(conf)) {
ERR("error creating limiter\n");
}
char buf[1024];
- log_config_read_file(conf, filters_path); // not an error on failure - config still valid if missing, static rules apply
+ log_config_read_file(conf, config_path); // not an error on failure - config still valid if missing, static rules apply
__log_limiter_update(conf);
struct rule *r = NULL;
return EXIT_FAILURE;
}
- const char *const extra_filters_path = log_config_get(&conf, DYNAMIC_FILTERS_CONF_KEY);
- if (!extra_filters_path) {
- printf("Dynamic filters are disabled (\"%s\" not defined in config)\n", DYNAMIC_FILTERS_CONF_KEY);
+ const char *const extra_config_path = log_config_get(&conf, DYNAMIC_CONFIG_CONF_KEY);
+ if (!extra_config_path) {
+ printf("Dynamic config is disabled (\"%s\" not defined in config)\n", DYNAMIC_CONFIG_CONF_KEY);
return EXIT_SUCCESS;
}
__attribute__ ((cleanup(free_ptr))) char *full_inotify_path = NULL;
- if (asprintf(&full_inotify_path, "%s/%s", extra_filters_path, DYNAMIC_FILTERS_FILENAME) < 0) {
+ if (asprintf(&full_inotify_path, "%s/%s", extra_config_path, DYNAMIC_CONFIG_FILENAME) < 0) {
full_inotify_path = NULL;
ERR("asprintf: no memory");
return EXIT_FAILURE;
// DLOG
#include <dlog.h>
+#include <dynamic_config.h>
#include <logcommon.h>
-#include <log_filters.h>
#include <loglimiter.h>
-#define FILTERS_CONF "/tmp/dlog-filters/" DYNAMIC_FILTERS_FILENAME
+#define DYNAMIC_CONF "/tmp/dlog-filters/" DYNAMIC_CONFIG_FILENAME
#define BUF_LEN (MAX_CONF_KEY_LEN + MAX_CONF_VAL_LEN + 3) // +3 because KEY=VAL\n\0
#define FILTER_ALLOW (__LOG_LIMITER_LIMIT_MAX + 1)
char buf[BUF_LEN];
const int flags = O_CREAT | O_WRONLY | flag;
- __attribute__ ((cleanup(close_fd))) const int fd = open(FILTERS_CONF, flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
+ __attribute__ ((cleanup(close_fd))) const int fd = open(DYNAMIC_CONF, flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
if (fd < 0) {
- perror("error opening filters conf file");
+ perror("error opening dynamic conf file");
return -errno;
}
int erase_file()
{
- __attribute__ ((cleanup(close_fd))) const int fd = open(FILTERS_CONF, O_RDWR|O_TRUNC);
+ __attribute__ ((cleanup(close_fd))) const int fd = open(DYNAMIC_CONF, O_RDWR|O_TRUNC);
if (fd < 0) {
- perror("error opening filters conf file");
+ perror("error opening dynamic conf file");
return -errno;
}