Commit | Line | Data |
---|---|---|
cbe2ebd6 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: LGPL-2.1-only |
cbe2ebd6 | 3 | * |
c0c0989a MJ |
4 | * Copyright (C) 2016 EfficiOS Inc. |
5 | * Copyright (C) 2016 Alexandre Montplaisir <alexmonthy@efficios.com> | |
cbe2ebd6 AM |
6 | */ |
7 | ||
8 | package org.lttng.ust.agent.utils; | |
9 | ||
10 | /** | |
11 | * Logging infrastructure for the lttng-ust Java agent. It prints log messages | |
12 | * to stderr but only when the environment variable LTTNG_UST_DEBUG is defined. | |
13 | * | |
14 | * @author Alexandre Montplaisir | |
15 | */ | |
16 | public class LttngUstAgentLogger { | |
17 | ||
18 | private static final String ENV_VAR_NAME = "LTTNG_UST_DEBUG"; | |
19 | private static final boolean LOGGING_ENABLED = (System.getenv(ENV_VAR_NAME) == null ? false : true); | |
20 | ||
21 | /** | |
22 | * Log event. Will be printed to stderr if the environment variable | |
23 | * "LTTNG_UST_DEBUG" is defined. | |
24 | * | |
25 | * @param c | |
26 | * The class logging the message (should normally be called with | |
27 | * {@link #getClass()}). | |
28 | * @param message | |
29 | * The message to print | |
30 | */ | |
31 | public static void log(Class<?> c, String message) { | |
32 | if (LOGGING_ENABLED) { | |
33 | System.err.println(c.getSimpleName() + ": " + message); | |
34 | } | |
35 | } | |
36 | } |