2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2016 EfficiOS Inc.
5 * Copyright (C) 2016 Alexandre Montplaisir <alexmonthy@efficios.com>
8 package org.lttng.ust.agent.utils;
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.
14 * @author Alexandre Montplaisir
16 public class LttngUstAgentLogger {
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);
22 * Log event. Will be printed to stderr if the environment variable
23 * "LTTNG_UST_DEBUG" is defined.
26 * The class logging the message (should normally be called with
27 * {@link #getClass()}).
29 * The message to print
31 public static void log(Class<?> c, String message) {
32 if (LOGGING_ENABLED) {
33 System.err.println(c.getSimpleName() + ": " + message);