/src/main/java/me/taahanis/projectalpha/util/AlphaLog.java
https://bitbucket.org/thatonekid/projectalpha · Java · 94 lines · 63 code · 22 blank · 9 comment · 7 complexity · 55f2fdd5413727a2ec31041c3b4d76ab MD5 · raw file
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package me.taahanis.projectalpha.util;
-
- import java.util.logging.Level;
- import java.util.logging.Logger;
-
- public class AlphaLog {
-
- private static final Logger FALLBACK_LOGGER = Logger.getLogger("Minecraft-Server");
- private static Logger serverLogger = null;
- private static Logger pluginLogger = null;
-
- private AlphaLog() {
- throw new AssertionError();
- }
-
- // Level.INFO:
- public static void info(String message) {
- info(message, false);
- }
-
- public static void info(String message, Boolean raw) {
- log(Level.INFO, message, raw);
- }
-
- public static void info(Throwable ex) {
- log(Level.INFO, ex);
- }
-
- // Level.WARNING:
- public static void warning(String message) {
- warning(message, false);
- }
-
- public static void warning(String message, Boolean raw) {
- log(Level.WARNING, message, raw);
- }
-
- public static void warning(Throwable ex) {
- log(Level.WARNING, ex);
- }
-
- // Level.SEVERE:
- public static void severe(String message) {
- severe(message, false);
- }
-
- public static void severe(String message, Boolean raw) {
- log(Level.SEVERE, message, raw);
- }
-
- public static void severe(Throwable ex) {
- log(Level.SEVERE, ex);
- }
-
- // Utility
- private static void log(Level level, String message, boolean raw) {
- getLogger(raw).log(level, message);
- }
-
- private static void log(Level level, Throwable throwable) {
- getLogger(false).log(level, null, throwable);
- }
-
- public static void setServerLogger(Logger logger) {
- serverLogger = logger;
- }
-
- public static void setPluginLogger(Logger logger) {
- pluginLogger = logger;
- }
-
- private static Logger getLogger(boolean raw) {
- if (raw || pluginLogger == null) {
- return (serverLogger != null ? serverLogger : FALLBACK_LOGGER);
- } else {
- return pluginLogger;
- }
- }
-
- public static Logger getPluginLogger() {
- return (pluginLogger != null ? pluginLogger : FALLBACK_LOGGER);
- }
-
- public static Logger getServerLogger() {
- return (serverLogger != null ? serverLogger : FALLBACK_LOGGER);
- }
-
- }