Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7a9e2f60d2734aa9107cf34861b7f454ae63b301 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
 * Copyright (c) 2008 Heiko Seeberger and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Heiko Seeberger - initial implementation
 *******************************************************************************/

package org.eclipse.equinox.weaving.internal.caching;

import static org.eclipse.equinox.weaving.internal.caching.IBundleConstants.BUNDLE_SYMBOLIC_NAME;

/**
 * Logging utility.
 * 
 * @author Heiko Seeberger
 */
public class Log {

    static boolean debugEnabled = false;

    private static final String PREFIX = "[" + BUNDLE_SYMBOLIC_NAME + "] "; //$NON-NLS-1$ //$NON-NLS-2$

    /**
     * Logging debug information.
     * 
     * @param message
     *            The tracing message, optional.
     */
    public static void debug(final String message) {
        if (debugEnabled) {
            if (message != null) {
                System.out.println(PREFIX + message);
            }
        }
    }

    /**
     * Logging an error.
     * 
     * @param message
     *            The error message, optional.
     * @param t
     *            The Throwable for this error, optional.
     */
    public static void error(final String message, final Throwable t) {
        if (message != null) {
            System.err.println(PREFIX + message);
        }
        if (t != null) {
            t.printStackTrace(System.err);
        }
    }

    /**
     * Shows debug toggle state.
     * 
     * @return true, if debug is enabled, else false.
     */
    public static boolean isDebugEnabled() {
        return debugEnabled;
    }
}

Back to the top