* limitations under the License. */
#include <dlogutil.h>
+#include <logprint.h>
#ifdef __cplusplus
extern "C" {
struct dlogutil_config {
- // TODO: Consider making this not a pointer
- struct log_filter *filter;
+ struct log_filter filter;
unsigned int logs_size;
dlogutil_sorting_order_e sort_by;
unsigned int buffers;
struct log_filter *log_filter_new();
void log_filter_free(struct log_filter *p_filter);
+struct log_filter {
+ list_head filters;
+ log_priority global_pri;
+ bool exact_global_pri;
+ bool need_apply_default;
+};
+
+void log_filter_init(struct log_filter *p_filter);
struct log_write_buffer log_write_buffer_new();
#include <tizen.h>
#include <logcommon.h>
-static void filter_options_destroy(struct log_filter **filter)
-{
- log_filter_free(*filter);
-}
-
EXPORT_API dlogutil_config_s *dlogutil_config_create(void)
{
- __attribute__((cleanup(filter_options_destroy))) struct log_filter *filter = log_filter_new();
-
- if (!filter)
- return NULL;
-
dlogutil_config_s *ret = calloc(1, sizeof(*ret));
if (!ret)
return NULL;
ret->mode = DLOGUTIL_MODE_NONPRINTING;
ret->logs_size = DEFAULT_SORT_BUFFER_SIZE;
ret->sort_by = DLOGUTIL_SORT_DEFAULT;
- ret->filter = filter;
- filter = NULL;
+ log_filter_init(&ret->filter);
return ret;
}
if (!config)
return;
- log_filter_free(config->filter);
+ log_filter_clear(&config->filter);
free(config);
}
EXPORT_API int dlogutil_config_filter_tid(dlogutil_config_s *config, pid_t tid)
{
CHECK_PARAM(config);
- return log_filter_set_tid(config->filter, tid);
+ return log_filter_set_tid(&config->filter, tid);
}
EXPORT_API int dlogutil_config_filter_pid(dlogutil_config_s *config, pid_t pid)
{
CHECK_PARAM(config);
- return log_filter_set_pid(config->filter, pid);
+ return log_filter_set_pid(&config->filter, pid);
}
EXPORT_API int dlogutil_config_filter_filterspec(dlogutil_config_s *config, const char *query)
{
CHECK_PARAM(config);
- return log_filter_set_filterspec(config->filter, query);
+ return log_filter_set_filterspec(&config->filter, query);
}
EXPORT_API int dlogutil_config_sorting_disable(dlogutil_config_s *config)
state->aliased[i] = aliased[i];
sort_vector_init(&state->logs);
- state->filter_object = config->filter ? log_filter_from_filter(config->filter) : log_filter_new();
+ state->filter_object = log_filter_from_filter(&config->filter);
state->epollfd = epoll_create1(0);
if (state->epollfd < 0)
#define FILTERINFO_PID_NONE -1
#define FILTERINFO_TID_NONE -1
-struct log_filter {
- list_head filters;
- log_priority global_pri;
- bool exact_global_pri;
- bool need_apply_default;
-};
-
/**
* @brief Allocate filter info
* @details Allocates filter info with given parameters
return p_filter->need_apply_default;
}
+void log_filter_init(struct log_filter *p_filter)
+{
+ p_filter->global_pri = DLOG_SILENT;
+ p_filter->exact_global_pri = false;
+ p_filter->need_apply_default = true;
+}
+
/**
* @brief Allocate log format
* @details Allocates a log format structure
if (!p_ret)
return NULL;
- p_ret->global_pri = DLOG_SILENT;
- p_ret->exact_global_pri = false;
- p_ret->need_apply_default = true;
+ log_filter_init(p_ret);
return p_ret;
}