Skip to content

Commit

Permalink
Added: Debug message support in the LogManager
Browse files Browse the repository at this point in the history
Refactored: File structure for the "wrappers"
  • Loading branch information
Bram1903 committed Apr 27, 2024
1 parent 52c1b33 commit 947765b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.deathmotion.antihealthindicator.wrappers.interfaces;
package com.deathmotion.antihealthindicator.interfaces;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* This file is part of AntiHealthIndicator - https://github.com/Bram1903/AntiHealthIndicator
* Copyright (C) 2024 Bram and contributors
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.deathmotion.antihealthindicator.managers;

import com.deathmotion.antihealthindicator.AHIPlatform;
import com.deathmotion.antihealthindicator.enums.ConfigOption;

import java.util.logging.Logger;

/**
* LogManager class to handle all kinds of logging messages.
* This class supports logging info, warning, error and debug messages.
*
* @param <P> the platform type.
*/
public final class LogManager<P> {
private final Logger logger = Logger.getLogger("AntiHealthIndicator");
private final boolean debugEnabled;

/**
* A constructor to initialize LogManager.
*
* @param platform AHIPlatform instance with platform-specific configurations.
*/
public LogManager(AHIPlatform<P> platform) {
this.debugEnabled = platform.getConfigurationOption(ConfigOption.DEBUG_ENABLED);
}

/**
* Logs the information messages
*
* @param message the message to be logged as info
*/
public void info(String message) {
logger.info(message);
}

/**
* Logs the warning messages
*
* @param message the message to be logged as warning
*/
public void warning(String message) {
logger.warning(message);
}

/**
* Logs the error messages
*
* @param message the message to be logged as error
*/
public void error(String message) {
logger.severe(message);
}

/**
* Logs the debug messages, but only if debug mode is enabled.
*
* @param message the message to be logged as debug
*/
public void debug(String message) {
if (debugEnabled) {
logger.info("[DEBUG] " + message);
}
}
}

This file was deleted.

0 comments on commit 947765b

Please sign in to comment.