jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Debug.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2020 Gothel Software e.K.
4 * Copyright (c) 2012 Gothel Software e.K.
5 * Copyright (c) 2012 JogAmp Community.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27package org.jau.sys;
28
29import java.security.PrivilegedAction;
30
31import org.jau.sec.SecurityUtil;
32
33/** Helper routines for logging and debugging. */
34
35public class Debug extends PropertyAccess {
36 // Some common properties
37 private static final boolean verbose;
38 private static final boolean debugAll;
39
40 static {
41 SecurityUtil.doPrivileged(new PrivilegedAction<Object>() {
42 @Override
43 public Object run() {
45 return null;
46 } } );
47
48 verbose = isPropertyDefined("jau.verbose", true);
49 debugAll = isPropertyDefined("jau.debug", true);
50 }
51
52 /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */
53 public static final void initSingleton() {}
54
55 public static final boolean verbose() {
56 return verbose;
57 }
58
59 public static final boolean debugAll() {
60 return debugAll;
61 }
62
63 public static final boolean debug(final String subcomponent) {
64 return debugAll() || isPropertyDefined("jau.debug." + subcomponent, true);
65 }
66}
static< T > T doPrivileged(final PrivilegedAction< T > o)
Call wrapper for java.security.AccessController#doPrivileged(PrivilegedAction).
Helper routines for logging and debugging.
Definition: Debug.java:35
static final boolean debug(final String subcomponent)
Definition: Debug.java:63
static final void initSingleton()
Ensures static init block has been issues, i.e.
Definition: Debug.java:53
static final boolean debugAll()
Definition: Debug.java:59
static final boolean verbose()
Definition: Debug.java:55
Helper routines for accessing properties.
static final void addTrustedPrefix(final String prefix)
static final boolean isPropertyDefined(final String property, final boolean jnlpAlias)