2 * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_LOG_LEVEL_RULE_H
9 #define LTTNG_LOG_LEVEL_RULE_H
11 #include <lttng/lttng-export.h>
17 struct lttng_log_level_rule
;
19 enum lttng_log_level_rule_type
{
20 LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN
= -1,
21 LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY
= 0,
22 LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS
= 1,
25 enum lttng_log_level_rule_status
{
26 LTTNG_LOG_LEVEL_RULE_STATUS_OK
= 0,
27 LTTNG_LOG_LEVEL_RULE_STATUS_ERROR
= -1,
28 LTTNG_LOG_LEVEL_RULE_STATUS_INVALID
= -3,
32 * Returns the type of the log level rule `rule`, or:
34 * `LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN`:
37 LTTNG_EXPORT
extern enum lttng_log_level_rule_type
38 lttng_log_level_rule_get_type(const struct lttng_log_level_rule
*rule
);
41 * Creates a log level rule for which a log level must match exactly `level` to
46 * * There's a memory error.
48 * The returned log level rule must be destroyed using
49 * lttng_log_level_rule_destroy().
51 LTTNG_EXPORT
extern struct lttng_log_level_rule
*lttng_log_level_rule_exactly_create(int level
);
54 * Sets `level` to the level of the "exactly" log level rule `rule`.
58 * `LTTNG_LOG_LEVEL_RULE_STATUS_OK`:
61 * `LTTNG_LOG_LEVEL_RULE_STATUS_INVALID`:
64 * * The type of `rule` is not `LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY`.
66 LTTNG_EXPORT
extern enum lttng_log_level_rule_status
67 lttng_log_level_rule_exactly_get_level(const struct lttng_log_level_rule
*rule
, int *level
);
70 * Creates a log level rule for which a log level must be at least as severe as
71 * `level` to be considered.
75 * * There's a memory error.
77 * The returned log level rule must be destroyed using
78 * lttng_log_level_rule_destroy().
80 LTTNG_EXPORT
extern struct lttng_log_level_rule
*
81 lttng_log_level_rule_at_least_as_severe_as_create(int level
);
84 * Sets `level` to the level of the "at least as severe as" log level rule
89 * `LTTNG_LOG_LEVEL_RULE_STATUS_OK`:
92 * `LTTNG_LOG_LEVEL_RULE_STATUS_INVALID`:
95 * * The type of `rule` is not
96 * `LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS`.
98 LTTNG_EXPORT
extern enum lttng_log_level_rule_status
99 lttng_log_level_rule_at_least_as_severe_as_get_level(const struct lttng_log_level_rule
*rule
,
103 * Destroy the log level rule `log_level_rule` if not `NULL`.
105 LTTNG_EXPORT
extern void lttng_log_level_rule_destroy(struct lttng_log_level_rule
*log_level_rule
);
111 #endif /* LTTNG_LOG_LEVEL_RULE_H */