Hide internal tracepoint and providers data symbols
[lttng-ust.git] / src / lib / lttng-ust-java-agent / jni / log4j / lttng_ust_log4j.c
CommitLineData
43e5396b 1/*
c0c0989a 2 * SPDX-License-Identifier: LGPL-2.1-only
43e5396b 3 *
c0c0989a
MJ
4 * Copyright (C) 2016 EfficiOS Inc.
5 * Copyright (C) 2016 Alexandre Montplaisir <alexmonthy@efficios.com>
6 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
43e5396b
DG
7 */
8
1ddceb36 9#define _LGPL_SOURCE
6e7bc9e0 10#include "org_lttng_ust_agent_log4j_LttngLog4jApi.h"
43e5396b 11
6ba0c2b2
MD
12#define LTTNG_UST_TRACEPOINT_HIDDEN_DEFINITION
13#define LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION
14
88c7c4ea 15#define LTTNG_UST_TRACEPOINT_DEFINE
660323e6 16#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
501f6777 17#include "lttng_ust_log4j.h"
8ab5c06b 18#include "../common/lttng_ust_context.h"
43e5396b 19
9aabed2d 20/*
8ab5c06b 21 * Deprecated function from before the context information was passed.
9aabed2d 22 */
6e7bc9e0 23JNIEXPORT void JNICALL Java_org_lttng_ust_agent_log4j_LttngLog4jApi_tracepoint(JNIEnv *env,
2208d8b5 24 jobject jobj __attribute__((unused)),
43e5396b
DG
25 jstring msg,
26 jstring logger_name,
27 jstring class_name,
28 jstring method_name,
501f6777
CB
29 jstring file_name,
30 jint line_number,
31 jlong timestamp,
32 jint loglevel,
33 jstring thread_name)
43e5396b
DG
34{
35 jboolean iscopy;
36 const char *msg_cstr = (*env)->GetStringUTFChars(env, msg, &iscopy);
37 const char *logger_name_cstr = (*env)->GetStringUTFChars(env, logger_name, &iscopy);
38 const char *class_name_cstr = (*env)->GetStringUTFChars(env, class_name, &iscopy);
39 const char *method_name_cstr = (*env)->GetStringUTFChars(env, method_name, &iscopy);
501f6777
CB
40 const char *file_name_cstr = (*env)->GetStringUTFChars(env, file_name, &iscopy);
41 const char *thread_name_cstr = (*env)->GetStringUTFChars(env, thread_name, &iscopy);
43e5396b 42
cbc06a3b 43 lttng_ust_tracepoint(lttng_log4j, event, msg_cstr, logger_name_cstr,
501f6777
CB
44 class_name_cstr, method_name_cstr, file_name_cstr,
45 line_number, timestamp, loglevel, thread_name_cstr);
9aabed2d
DG
46
47 (*env)->ReleaseStringUTFChars(env, msg, msg_cstr);
48 (*env)->ReleaseStringUTFChars(env, logger_name, logger_name_cstr);
49 (*env)->ReleaseStringUTFChars(env, class_name, class_name_cstr);
50 (*env)->ReleaseStringUTFChars(env, method_name, method_name_cstr);
501f6777
CB
51 (*env)->ReleaseStringUTFChars(env, file_name, file_name_cstr);
52 (*env)->ReleaseStringUTFChars(env, thread_name, thread_name_cstr);
9aabed2d
DG
53}
54
8ab5c06b
AM
55/*
56 * Tracepoint used by Java applications using the log4j handler.
57 */
58JNIEXPORT void JNICALL Java_org_lttng_ust_agent_log4j_LttngLog4jApi_tracepointWithContext(JNIEnv *env,
2208d8b5 59 jobject jobj __attribute__((unused)),
8ab5c06b
AM
60 jstring msg,
61 jstring logger_name,
62 jstring class_name,
63 jstring method_name,
64 jstring file_name,
65 jint line_number,
66 jlong timestamp,
67 jint loglevel,
68 jstring thread_name,
b1ca4c5f
AM
69 jbyteArray context_info_entries,
70 jbyteArray context_info_strings)
8ab5c06b
AM
71{
72 jboolean iscopy;
73 const char *msg_cstr = (*env)->GetStringUTFChars(env, msg, &iscopy);
74 const char *logger_name_cstr = (*env)->GetStringUTFChars(env, logger_name, &iscopy);
75 const char *class_name_cstr = (*env)->GetStringUTFChars(env, class_name, &iscopy);
76 const char *method_name_cstr = (*env)->GetStringUTFChars(env, method_name, &iscopy);
77 const char *file_name_cstr = (*env)->GetStringUTFChars(env, file_name, &iscopy);
78 const char *thread_name_cstr = (*env)->GetStringUTFChars(env, thread_name, &iscopy);
b1ca4c5f
AM
79 signed char *context_info_entries_array;
80 signed char *context_info_strings_array;
8ab5c06b
AM
81
82 /*
83 * Write these to the TLS variables, so that the UST callbacks in
84 * lttng_ust_context.c can access them.
85 */
b1ca4c5f
AM
86 context_info_entries_array = (*env)->GetByteArrayElements(env, context_info_entries, &iscopy);
87 lttng_ust_context_info_tls.ctx_entries = (struct lttng_ust_jni_ctx_entry *) context_info_entries_array;
88 lttng_ust_context_info_tls.ctx_entries_len = (*env)->GetArrayLength(env, context_info_entries);
89 context_info_strings_array = (*env)->GetByteArrayElements(env, context_info_strings, &iscopy);
90 lttng_ust_context_info_tls.ctx_strings = context_info_strings_array;
91 lttng_ust_context_info_tls.ctx_strings_len = (*env)->GetArrayLength(env, context_info_strings);
8ab5c06b 92
cbc06a3b 93 lttng_ust_tracepoint(lttng_log4j, event, msg_cstr, logger_name_cstr,
8ab5c06b
AM
94 class_name_cstr, method_name_cstr, file_name_cstr,
95 line_number, timestamp, loglevel, thread_name_cstr);
96
b1ca4c5f
AM
97 lttng_ust_context_info_tls.ctx_entries = NULL;
98 lttng_ust_context_info_tls.ctx_entries_len = 0;
99 lttng_ust_context_info_tls.ctx_strings = NULL;
100 lttng_ust_context_info_tls.ctx_strings_len = 0;
8ab5c06b
AM
101 (*env)->ReleaseStringUTFChars(env, msg, msg_cstr);
102 (*env)->ReleaseStringUTFChars(env, logger_name, logger_name_cstr);
103 (*env)->ReleaseStringUTFChars(env, class_name, class_name_cstr);
104 (*env)->ReleaseStringUTFChars(env, method_name, method_name_cstr);
105 (*env)->ReleaseStringUTFChars(env, file_name, file_name_cstr);
106 (*env)->ReleaseStringUTFChars(env, thread_name, thread_name_cstr);
b1ca4c5f
AM
107 (*env)->ReleaseByteArrayElements(env, context_info_entries, context_info_entries_array, 0);
108 (*env)->ReleaseByteArrayElements(env, context_info_strings, context_info_strings_array, 0);
8ab5c06b 109}
This page took 0.032844 seconds and 4 git commands to generate.