Fix: disable event for JUL domain
[lttng-tools.git] / src / bin / lttng-sessiond / jul.h
CommitLineData
0475c50c
DG
1/*
2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
96090c92
MD
18#ifndef LTTNG_SESSIOND_JUL_H
19#define LTTNG_SESSIOND_JUL_H
0475c50c 20
f20baf8e
DG
21#define _GNU_SOURCE
22#include <inttypes.h>
23
0475c50c
DG
24#include <common/hashtable/hashtable.h>
25#include <lttng/lttng.h>
26
f20baf8e
DG
27/*
28 * Hash table that contains the JUL app created upon registration indexed by
29 * socket.
30 */
31struct lttng_ht *jul_apps_ht_by_sock;
32
d0c4850f
DG
33struct jul_ht_key {
34 const char *name;
35 enum lttng_loglevel_jul loglevel;
36};
37
f20baf8e
DG
38/*
39 * Registration message payload from a JUL application. The PID is used to find
40 * back the corresponding UST app object so both socket can be linked.
41 */
42struct jul_register_msg {
43 uint32_t pid;
44};
45
46/*
6657149e
MD
47 * JUL application object created after a successful registration. This
48 * object is linked to its associated UST app by their PID through hash
49 * table lookups.
f20baf8e
DG
50 */
51struct jul_app {
52 /*
53 * PID sent during registration of a JUL application.
54 */
55 pid_t pid;
56
57 /*
58 * JUL TCP socket that was created upon registration.
59 */
60 struct lttcomm_sock *sock;
61
f20baf8e
DG
62 /* Initialized with the JUL sock value. */
63 struct lttng_ht_node_ulong node;
64};
65
0475c50c
DG
66/*
67 * Java Util Logging event representation.
68 */
69struct jul_event {
70 /*
71 * Name of the event which is directly mapped to a Logger object name in
72 * the JUL API.
73 */
74 char name[LTTNG_SYMBOL_NAME_LEN];
e3a639d0
DG
75 enum lttng_loglevel_jul loglevel;
76 enum lttng_loglevel_type loglevel_type;
0475c50c
DG
77
78 /*
79 * Tells if the event is enabled or not on the JUL Agent.
80 */
81 unsigned int enabled:1;
82
83 /*
84 * Hash table nodes of the JUL domain. Indexed by name string.
85 */
86 struct lttng_ht_node_str node;
56fa021b
DG
87
88 /*
89 * Filter that we keep to use it to disable an event.
90 */
91 struct lttng_filter_bytecode *filter;
0475c50c
DG
92};
93
94/*
95 * Top level data structure in a UST session containing JUL event name created
96 * for it.
97 */
98struct jul_domain {
3c6a091f
DG
99 /*
100 * This indicates if that domain is being used meaning if at least one
101 * event has been at some point in time added to it. This is used so when
102 * listing domains for a session, we can tell or not if the JUL is actually
103 * enabled.
104 */
105 unsigned int being_used:1;
0475c50c
DG
106 /*
107 * Contains JUL event indexed by name.
108 */
109 struct lttng_ht *events;
110};
111
f20baf8e
DG
112/* Initialize JUL domain subsystem. */
113int jul_init(void);
114
115/* Initialize an already allocated JUL domain. */
0475c50c 116int jul_init_domain(struct jul_domain *dom);
f20baf8e
DG
117void jul_destroy_domain(struct jul_domain *dom);
118
119/* JUL event API. */
0475c50c
DG
120struct jul_event *jul_create_event(const char *name);
121void jul_add_event(struct jul_event *event, struct jul_domain *dom);
d0c4850f
DG
122struct jul_event *jul_find_event(const char *name,
123 enum lttng_loglevel_jul loglevel, struct jul_domain *dom);
124struct jul_event *jul_find_event_by_name(const char *name,
125 struct jul_domain *dom);
0475c50c
DG
126void jul_delete_event(struct jul_event *event, struct jul_domain *dom);
127void jul_destroy_event(struct jul_event *event);
f20baf8e
DG
128
129/* JUL app API. */
130struct jul_app *jul_create_app(pid_t pid, struct lttcomm_sock *sock);
131void jul_add_app(struct jul_app *app);
132void jul_delete_app(struct jul_app *app);
133struct jul_app *jul_find_app_by_sock(int sock);
f20baf8e 134void jul_destroy_app(struct jul_app *app);
cf9787ee 135int jul_send_registration_done(struct jul_app *app);
f20baf8e
DG
136
137/* JUL action API */
138int jul_enable_event(struct jul_event *event);
139int jul_disable_event(struct jul_event *event);
140void jul_update(struct jul_domain *domain, int sock);
3c6a091f 141int jul_list_events(struct lttng_event **events);
0475c50c 142
96090c92 143#endif /* LTTNG_SESSIOND_JUL_H */
This page took 0.029195 seconds and 4 git commands to generate.