All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jorigin.Common Maven / Gradle / Ivy

There is a newer version: 1.0.14
Show newest version
/*
  This file is part of JOrigin Common Library.

    JOrigin Common is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    JOrigin Common is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with JOrigin Common.  If not, see .
    
*/
package org.jorigin;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.jorigin.logging.LogHandler;

/**
 * The information class about the Common libraries for JOrigin project.
 * This class is only used for gathering informations about the Common libraries.
* The logging level of the common logger can be set by the system property java.util.logging.level with values: *
    *
  • OFF *
  • SEVERE *
  • WARNING *
  • INFO *
  • CONFIG *
  • FINE *
  • FINER *
  • FINEST *
  • ALL *
* When a value is set, all level above are implicitly included. For example, a level FINE enable also CONFIG, INFO, * WARNING and SEVERE. * @author Julien Seinturier - COMEX S.A. - [email protected] - https://github.com/jorigin/jeometry * @version {@value Common#version} - b{@value Common#BUILD} * @since 1.0.0 */ public class Common { /** * The {@link java.util.logging.Logger logger} used for reporting. */ public static Logger logger = null; static { init(); } /** * The build version. */ public static final long BUILD = 201903071030L; /** * The version number */ public static final String version = "1.0.9"; /** * Initialize the JOrigin common package. */ public static final void init(){ logger = Logger.getLogger("org.jorigin.Common"); LogHandler handler = new LogHandler(); String property = System.getProperty("java.util.logging.level"); Level level = Level.INFO; if (property != null){ if (property.equalsIgnoreCase("OFF")){ level = Level.OFF; } else if (property.equalsIgnoreCase("SEVERE")){ level = Level.SEVERE; } else if (property.equalsIgnoreCase("WARNING")){ level = Level.WARNING; } else if (property.equalsIgnoreCase("INFO")){ level = Level.INFO; } else if (property.equalsIgnoreCase("CONFIG")){ level = Level.CONFIG; } else if (property.equalsIgnoreCase("FINE")){ level = Level.FINE; } else if (property.equalsIgnoreCase("FINER")){ level = Level.FINER; } else if (property.equalsIgnoreCase("FINEST")){ level = Level.FINEST; } else if (property.equalsIgnoreCase("ALL")){ level = Level.ALL; } } handler.setLevel(level); logger.setLevel(level); logger.addHandler(handler); logger.setUseParentHandlers(false); } /** * Set the {@link java.util.logging.Logger logger} to use for reporting. * @param logger the {@link java.util.logging.Logger logger} to use for reporting. */ public static void setLogger(Logger logger){ Common.logger = logger; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy