|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is free software; you can redistribute it and/or modify it
|
|
Packit |
c04fcb |
* under the terms of the GNU Lesser General Public License, version 2.1 only,
|
|
Packit |
c04fcb |
* as published by the Free Software Foundation.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit |
c04fcb |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit |
c04fcb |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
Packit |
c04fcb |
* for more details.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
c04fcb |
* along with this library; if not, write to the Free Software Foundation,
|
|
Packit |
c04fcb |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
package org.lttng.ust.agent.utils;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/**
|
|
Packit |
c04fcb |
* Logging infrastructure for the lttng-ust Java agent. It prints log messages
|
|
Packit |
c04fcb |
* to stderr but only when the environment variable LTTNG_UST_DEBUG is defined.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* @author Alexandre Montplaisir
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
public class LttngUstAgentLogger {
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
private static final String ENV_VAR_NAME = "LTTNG_UST_DEBUG";
|
|
Packit |
c04fcb |
private static final boolean LOGGING_ENABLED = (System.getenv(ENV_VAR_NAME) == null ? false : true);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/**
|
|
Packit |
c04fcb |
* Log event. Will be printed to stderr if the environment variable
|
|
Packit |
c04fcb |
* "LTTNG_UST_DEBUG" is defined.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* @param c
|
|
Packit |
c04fcb |
* The class logging the message (should normally be called with
|
|
Packit |
c04fcb |
* {@link #getClass()}).
|
|
Packit |
c04fcb |
* @param message
|
|
Packit |
c04fcb |
* The message to print
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
public static void log(Class c, String message) {
|
|
Packit |
c04fcb |
if (LOGGING_ENABLED) {
|
|
Packit |
c04fcb |
System.err.println(c.getSimpleName() + ": " + message);
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
}
|