#605 Add custom log levels, create debug logging method

- Log levels in the log file too
- Create migration from old boolean "stop spam" property to new log level property
This commit is contained in:
ljacqu
2016-07-22 17:45:00 +02:00
parent 0eb1890cf9
commit a8df8ceb09
14 changed files with 218 additions and 88 deletions
@@ -8,9 +8,11 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.output.LogLevel;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.command.CommandSender;
import org.junit.Before;
@@ -67,7 +69,7 @@ public class ReloadCommandTest {
@Before
public void setDefaultSettings() {
// Mock properties retrieved by ConsoleLogger
given(settings.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)).willReturn(false);
given(settings.getProperty(PluginSettings.LOG_LEVEL)).willReturn(LogLevel.INFO);
given(settings.getProperty(SecuritySettings.USE_LOGGING)).willReturn(false);
}
@@ -0,0 +1,31 @@
package fr.xephi.authme.output;
import org.junit.Test;
import static java.lang.String.format;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
/**
* Test for {@link LogLevel}.
*/
public class LogLevelTest {
@Test
public void shouldIncludeProperLevels() {
checkLevelInclusion(LogLevel.INFO, true, false, false);
checkLevelInclusion(LogLevel.FINE, true, true, false);
checkLevelInclusion(LogLevel.DEBUG, true, true, true);
}
private void checkLevelInclusion(LogLevel level, boolean... expectedValues) {
LogLevel[] levels = LogLevel.values();
assertThat("Number of expected values corresponds to number of log levels",
expectedValues.length, equalTo(levels.length));
for (int i = 0; i < levels.length; ++i) {
assertThat(format("%s.includes(%s) should be %b", level, levels[i], expectedValues[i]),
level.includes(levels[i]), equalTo(expectedValues[i]));
}
}
}