Commit | Line | Data |
---|---|---|
85b05318 JR |
1 | /* |
2 | * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: LGPL-2.1-only | |
5 | * | |
6 | */ | |
7 | ||
8 | #ifndef LTTNG_LOG_LEVEL_RULE_H | |
9 | #define LTTNG_LOG_LEVEL_RULE_H | |
10 | ||
11 | #ifdef __cplusplus | |
12 | extern "C" { | |
13 | #endif | |
14 | ||
15 | struct lttng_log_level_rule; | |
16 | ||
17 | enum lttng_log_level_rule_type { | |
18 | LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN = -1, | |
19 | LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY = 0, | |
20 | LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS = 1, | |
21 | }; | |
22 | ||
23 | enum lttng_log_level_rule_status { | |
24 | LTTNG_LOG_LEVEL_RULE_STATUS_OK = 0, | |
25 | LTTNG_LOG_LEVEL_RULE_STATUS_ERROR = -1, | |
26 | LTTNG_LOG_LEVEL_RULE_STATUS_INVALID = -3, | |
27 | }; | |
28 | ||
29 | /* | |
30 | * Returns the type of the log level rule `rule`, or: | |
31 | * | |
32 | * `LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN`: | |
33 | * `rule` is `NULL`. | |
34 | */ | |
35 | extern enum lttng_log_level_rule_type lttng_log_level_rule_get_type( | |
36 | const struct lttng_log_level_rule *rule); | |
37 | ||
38 | /* | |
39 | * Creates a log level rule for which a log level must match exactly `level` to | |
40 | * be considered. | |
41 | * | |
42 | * Returns `NULL` if: | |
43 | * | |
44 | * * There's a memory error. | |
45 | * | |
46 | * The returned log level rule must be destroyed using | |
47 | * lttng_log_level_rule_destroy(). | |
48 | */ | |
49 | extern struct lttng_log_level_rule *lttng_log_level_rule_exactly_create( | |
50 | int level); | |
51 | ||
52 | /* | |
53 | * Sets `level` to the level of the "exactly" log level rule `rule`. | |
54 | * | |
55 | * Returns: | |
56 | * | |
57 | * `LTTNG_LOG_LEVEL_RULE_STATUS_OK`: | |
58 | * Success. | |
59 | * | |
60 | * `LTTNG_LOG_LEVEL_RULE_STATUS_INVALID`: | |
61 | * * `rule` is NULL. | |
62 | * * `level` is NULL. | |
63 | * * The type of `rule` is not `LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY`. | |
64 | */ | |
65 | extern enum lttng_log_level_rule_status lttng_log_level_rule_exactly_get_level( | |
66 | const struct lttng_log_level_rule *rule, int *level); | |
67 | ||
68 | /* | |
69 | * Creates a log level rule for which a log level must be at least as severe as | |
70 | * `level` to be considered. | |
71 | * | |
72 | * Returns `NULL` if: | |
73 | * | |
74 | * * There's a memory error. | |
75 | * | |
76 | * The returned log level rule must be destroyed using | |
77 | * lttng_log_level_rule_destroy(). | |
78 | */ | |
79 | extern struct lttng_log_level_rule * | |
80 | lttng_log_level_rule_at_least_as_severe_as_create(int level); | |
81 | ||
82 | /* | |
83 | * Sets `level` to the level of the "at least as severe as" log level rule | |
84 | * `rule`. | |
85 | * | |
86 | * Returns: | |
87 | * | |
88 | * `LTTNG_LOG_LEVEL_RULE_STATUS_OK`: | |
89 | * Success. | |
90 | * | |
91 | * `LTTNG_LOG_LEVEL_RULE_STATUS_INVALID`: | |
92 | * * `rule` is NULL. | |
93 | * * `level` is NULL. | |
94 | * * The type of `rule` is not | |
95 | * `LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS`. | |
96 | */ | |
97 | extern enum lttng_log_level_rule_status | |
98 | lttng_log_level_rule_at_least_as_severe_as_get_level( | |
99 | const struct lttng_log_level_rule *rule, int *level); | |
100 | ||
101 | /* | |
102 | * Destroy the log level rule `log_level_rule` if not `NULL`. | |
103 | */ | |
104 | extern void lttng_log_level_rule_destroy( | |
105 | struct lttng_log_level_rule *log_level_rule); | |
106 | ||
107 | #ifdef __cplusplus | |
108 | } | |
109 | #endif | |
110 | ||
111 | #endif /* LTTNG_LOG_LEVEL_RULE_H */ |