001package net.tnemc.plugincore.core.compatibility; 002 003/* 004 * The New Plugin Core 005 * Copyright (C) 2022 - 2024 Daniel "creatorfromhell" Vidmar 006 * 007 * This program is free software: you can redistribute it and/or modify 008 * it under the terms of the GNU Affero General Public License as published by 009 * the Free Software Foundation, either version 3 of the License, or 010 * (at your option) any later version. 011 * 012 * This program is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 015 * GNU Affero General Public License for more details. 016 * 017 * You should have received a copy of the GNU Affero General Public License 018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 019 */ 020 021import net.tnemc.plugincore.core.compatibility.log.DebugLevel; 022 023/** 024 * Provides a compatibility layer for logging purposes. 025 * 026 * @author creatorfromhell 027 * @since 0.1.2.0 028 */ 029public interface LogProvider { 030 031 /** 032 * Sends an informative message, which doesn't contain an error or debug message. 033 * 034 * @param message The message to send. 035 */ 036 default void inform(String message) { 037 038 inform(message, DebugLevel.STANDARD); 039 } 040 041 /** 042 * Sends an informative message, which doesn't contain an error or debug message. 043 * 044 * @param message The message to send. 045 * @param level The {@link DebugLevel} to log this message at. 046 */ 047 void inform(String message, DebugLevel level); 048 049 /** 050 * Sends a message related to debug purposes. 051 * 052 * @param message The message to send. 053 */ 054 default void debug(String message) { 055 056 debug(message, DebugLevel.STANDARD); 057 } 058 059 /** 060 * Sends a message related to debug purposes. 061 * 062 * @param message The message to send. 063 * @param level The {@link DebugLevel} to log this message at. 064 */ 065 void debug(String message, DebugLevel level); 066 067 /** 068 * Sends a warning message. 069 * 070 * @param message The message to send. 071 */ 072 default void warning(String message) { 073 074 warning(message, DebugLevel.STANDARD); 075 } 076 077 /** 078 * Sends a warning message. 079 * 080 * @param message The message to send. 081 * @param level The {@link DebugLevel} to log this message at. 082 */ 083 void warning(String message, DebugLevel level); 084 085 /** 086 * Sends an error-related message. 087 * 088 * @param message The message to send. 089 */ 090 default void error(String message) { 091 092 error(message, DebugLevel.STANDARD); 093 } 094 095 /** 096 * Sends an error-related message. 097 * 098 * @param message The message to send. 099 * @param level The {@link DebugLevel} to log this message at. 100 */ 101 void error(String message, DebugLevel level); 102 103 /** 104 * Sends an error-related message. 105 * 106 * @param message The message to send. 107 * @param exception The error's {@link Exception}. 108 * @param level The {@link DebugLevel} to log this message at. 109 */ 110 void error(String message, Exception exception, DebugLevel level); 111 112 113 /** 114 * Sends an error that is SQL-related. 115 * 116 * @param message The message to send. 117 * @param exception The error's {@link Exception}. 118 * @param query The query string. 119 * @param variables An array of variables for the prepared statement. 120 * @param level The {@link DebugLevel} to log this message at. 121 */ 122 default void sqlError(String message, Exception exception, String query, Object[] variables, DebugLevel level) { 123 124 error("======= Query Error =======", level); 125 error(message, exception, level); 126 127 error("======= Query Statement =======", level); 128 error(query, level); 129 error("======= Query Variables Statement =======", level); 130 131 for(int i = 0; i < variables.length; i++) { 132 error("Variable - " + variables[i], level); 133 } 134 error("======= End Query Statement =======", level); 135 } 136}