diff options
Diffstat (limited to 'src/stats/stats-event-category.c')
-rw-r--r-- | src/stats/stats-event-category.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/stats/stats-event-category.c b/src/stats/stats-event-category.c new file mode 100644 index 0000000..cb01e8b --- /dev/null +++ b/src/stats/stats-event-category.c @@ -0,0 +1,32 @@ +/* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "stats-event-category.h" + +static pool_t categories_pool; + +void stats_event_category_register(const char *name, + struct event_category *parent) +{ + struct event_category *category = + p_new(categories_pool, struct event_category, 1); + category->parent = parent; + category->name = p_strdup(categories_pool, name); + + /* Create a temporary event to register the category. A bit slower + than necessary, but this code won't be called often. */ + struct event *event = event_create(NULL); + struct event_category *categories[] = { category, NULL }; + event_add_categories(event, categories); + event_unref(&event); +} + +void stats_event_categories_init(void) +{ + categories_pool = pool_alloconly_create("categories", 1024); +} + +void stats_event_categories_deinit(void) +{ + pool_unref(&categories_pool); +} |