Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replaced direct use of Java Logging with SLF4J, changed log format, c…

…hanged the level of many log statements to debug.
  • Loading branch information...
commit 21fedd2257df09e16656ad9df8f9c87e3e8a8876 1 parent 956302f
@immortius immortius authored
Showing with 655 additions and 615 deletions.
  1. +1 −1  applet/index.html
  2. +2 −0  build.gradle
  3. +4 −1 config/checkstyle/checkstyle.xml
  4. +8 −8 src/main/java/org/terasology/asset/AssetManager.java
  5. +14 −20 src/main/java/org/terasology/asset/AssetType.java
  6. +5 −8 src/main/java/org/terasology/asset/sources/AbstractSource.java
  7. +10 −8 src/main/java/org/terasology/asset/sources/ArchiveSource.java
  8. +6 −5 src/main/java/org/terasology/asset/sources/DirectorySource.java
  9. +6 −5 src/main/java/org/terasology/audio/OggStreamingSound.java
  10. +12 −8 src/main/java/org/terasology/audio/OpenALManager.java
  11. +5 −5 src/main/java/org/terasology/componentSystem/worldSimulation/GrowthSimulator.java
  12. +4 −4 src/main/java/org/terasology/config/Config.java
  13. +11 −11 src/main/java/org/terasology/entitySystem/metadata/ComponentLibraryImpl.java
  14. +8 −8 src/main/java/org/terasology/entitySystem/metadata/ComponentMetadata.java
  15. +6 −15 src/main/java/org/terasology/entitySystem/metadata/core/EnumTypeHandler.java
  16. +9 −9 src/main/java/org/terasology/entitySystem/metadata/core/MappedContainerTypeHandler.java
  17. +19 −19 src/main/java/org/terasology/entitySystem/persistence/EntityPersisterHelperImpl.java
  18. +8 −6 src/main/java/org/terasology/entitySystem/persistence/WorldPersister.java
  19. +4 −4 src/main/java/org/terasology/entitySystem/pojo/PojoEntityManager.java
  20. +9 −9 src/main/java/org/terasology/entitySystem/pojo/PojoEventSystem.java
  21. +12 −18 src/main/java/org/terasology/game/ComponentSystemManager.java
  22. +4 −5 src/main/java/org/terasology/game/Terasology.java
  23. +8 −7 src/main/java/org/terasology/game/TerasologyApplet.java
  24. +70 −20 src/main/java/org/terasology/game/TerasologyEngine.java
  25. +18 −18 src/main/java/org/terasology/game/modes/StateSinglePlayer.java
  26. +0 −2  src/main/java/org/terasology/input/InputSystem.java
  27. +0 −3  src/main/java/org/terasology/logic/manager/AudioManager.java
  28. +8 −8 src/main/java/org/terasology/logic/manager/CommandManager.java
  29. +7 −7 src/main/java/org/terasology/logic/manager/Config.java
  30. +13 −12 src/main/java/org/terasology/logic/manager/FontManager.java
  31. +20 −20 src/main/java/org/terasology/logic/manager/GUIManager.java
  32. +7 −5 src/main/java/org/terasology/logic/manager/PortalManager.java
  33. +7 −8 src/main/java/org/terasology/logic/manager/ShaderManager.java
  34. +9 −8 src/main/java/org/terasology/logic/mod/ModManager.java
  35. +4 −4 src/main/java/org/terasology/logic/mod/ModSecurityManager.java
  36. +6 −5 src/main/java/org/terasology/model/structures/BlockCollection.java
  37. +9 −8 src/main/java/org/terasology/model/structures/BlockSelection.java
  38. +7 −6 src/main/java/org/terasology/model/structures/CubicSelection.java
  39. +5 −4 src/main/java/org/terasology/network/Client.java
  40. +4 −5 src/main/java/org/terasology/network/Server.java
  41. +5 −5 src/main/java/org/terasology/network/TerasologyClientHandler.java
  42. +5 −7 src/main/java/org/terasology/network/TerasologyServerHandler.java
  43. +5 −5 src/main/java/org/terasology/physics/BulletPhysics.java
  44. +0 −3  src/main/java/org/terasology/physics/character/BulletCharacterMovementSystem.java
  45. +4 −2 src/main/java/org/terasology/rendering/assetLoaders/GLSLShaderLoader.java
  46. +5 −4 src/main/java/org/terasology/rendering/assetLoaders/ObjMeshLoader.java
  47. +6 −4 src/main/java/org/terasology/rendering/assetLoaders/PNGTextureLoader.java
  48. +9 −13 src/main/java/org/terasology/rendering/assetLoaders/md5/MD5AnimationLoader.java
  49. +8 −8 src/main/java/org/terasology/rendering/assetLoaders/md5/MD5SkeletonLoader.java
  50. +6 −5 src/main/java/org/terasology/rendering/assets/Material.java
  51. +12 −11 src/main/java/org/terasology/rendering/assets/Shader.java
  52. +6 −5 src/main/java/org/terasology/rendering/gui/widgets/UIImage.java
  53. +8 −10 src/main/java/org/terasology/rendering/gui/widgets/UIWindow.java
  54. +29 −27 src/main/java/org/terasology/rendering/gui/windows/UIMenuSingleplayer.java
  55. +5 −6 src/main/java/org/terasology/rendering/logic/MeshRenderer.java
  56. +5 −3 src/main/java/org/terasology/rendering/logic/SkeletonRenderer.java
  57. +38 −39 src/main/java/org/terasology/rendering/shader/ShaderProgram.java
  58. +9 −8 src/main/java/org/terasology/rendering/world/WorldRenderer.java
  59. +7 −6 src/main/java/org/terasology/version/TerasologyVersion.java
  60. +0 −4 src/main/java/org/terasology/world/EntityAwareWorldProvider.java
  61. +1 −4 src/main/java/org/terasology/world/WorldView.java
  62. +31 −31 src/main/java/org/terasology/world/block/Block.java
  63. +19 −18 src/main/java/org/terasology/world/block/loader/BlockLoader.java
  64. +5 −4 src/main/java/org/terasology/world/block/loader/TileLoader.java
  65. +6 −5 src/main/java/org/terasology/world/block/management/BlockManager.java
  66. +18 −17 src/main/java/org/terasology/world/chunks/LocalChunkProvider.java
  67. +6 −4 src/main/java/org/terasology/world/chunks/store/ChunkStoreFileSystem.java
  68. +14 −17 src/main/java/org/terasology/world/chunks/store/ChunkStoreGZip.java
  69. +4 −3 src/main/java/org/terasology/world/generator/core/FlatTerrainGenerator.java
  70. +4 −4 src/main/java/org/terasology/world/lighting/LightPropagator.java
  71. +6 −6 src/main/java/org/terasology/world/liquid/LiquidSimulator.java
View
2  applet/index.html
@@ -18,7 +18,7 @@
<applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="640" height="360">
<param name="al_title" value="Terasology">
<param name="al_main" value="org.terasology.game.TerasologyApplet">
- <param name="al_jars" value="lwjgl_applet.jar, lwjgl.jar, jinput.jar, lwjgl_util.jar, Terasology.jar, libs/lzma.jar, libs/slick.jar, libs/tera-bullet-1.0-SNAPSHOT.jar, libs/guava-13.0.1.jar, libs/gson-2.1.jar, libs/protobuf-java-2.4.1.jar, libs/trove4j-3.0.2.jar, libs/jorbis-0.0.17.jar, libs/netty-3.4.4.Final.jar, libs/reflections-0.9.8.jar, libs/vecmath-1.3.1.jar, libs/groovy-1.8.7.jar, libs/jutils-1.0.0.jar, libs/javassist-3.12.1.GA.jar, libs/xml-apis-1.0.b2.jar, libs/dom4j-1.6.1.jar libs/antlr-2.7.7.jar, libs/asm-3.2.jar, libs/asm-tree-3.2.jar, libs/asm-commons-3.2.jar, libs/asm-util-3.2.jar, libs/asm-analysis-3.2.jar">
+ <param name="al_jars" value="lwjgl_applet.jar, lwjgl.jar, jinput.jar, lwjgl_util.jar, Terasology.jar, libs/lzma.jar, libs/slick.jar, libs/tera-bullet-1.0-SNAPSHOT.jar, libs/guava-13.0.1.jar, libs/gson-2.1.jar, libs/protobuf-java-2.4.1.jar, libs/trove4j-3.0.2.jar, libs/jorbis-0.0.17.jar, libs/netty-3.4.4.Final.jar, libs/reflections-0.9.8.jar, libs/vecmath-1.3.1.jar, libs/groovy-1.8.7.jar, libs/jutils-1.0.0.jar, libs/javassist-3.12.1.GA.jar, libs/xml-apis-1.0.b2.jar, libs/dom4j-1.6.1.jar libs/antlr-2.7.7.jar, libs/asm-3.2.jar, libs/asm-tree-3.2.jar, libs/asm-commons-3.2.jar, libs/asm-util-3.2.jar, libs/asm-analysis-3.2.jar, libs/slf4j-api-1.7.2.jar, libs/slf4j-jdk14-1.7.2.jar">
<param name="al_windows" value="windows_natives.jar">
<param name="al_linux" value="linux_natives.jar">
<param name="al_mac" value="macosx_natives.jar">
View
2  build.gradle
@@ -103,6 +103,7 @@ configurations {
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.7'
+ compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.2'
compile group: 'com.google.guava', name: 'guava', version: '13.0.1'
compile group: 'com.google.code.gson', name: 'gson', version: '2.1'
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '2.4.1'
@@ -116,6 +117,7 @@ dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
testCompile group: 'junit', name: 'junit', version: '4.10'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.0'
+ runtime group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.2'
devCompile sourceSets.main.output
}
View
5 config/checkstyle/checkstyle.xml
@@ -21,7 +21,10 @@
<!-- See http://checkstyle.sourceforge.net/config_naming.html -->
<!-- ***************************** -->
<!-- constants (static, final fields) : ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ -->
- <module name="ConstantName"/>
+ <!-- Unfortunately this modules is too inclusive - static final fields are not necessarily constants! -->
+ <module name="ConstantName">
+ <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|logger)$"/>
+ </module>
<!-- local, final variables, including catch parameters : ^[a-z][a-zA-Z0-9]*$ -->
<module name="LocalFinalVariableName"/>
<!-- local, non-final variables, including catch parameters : ^[a-z][a-zA-Z0-9]*$ -->
View
16 src/main/java/org/terasology/asset/AssetManager.java
@@ -17,6 +17,8 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.common.NullIterator;
import org.terasology.logic.mod.ModManager;
import org.terasology.rendering.assets.Shader;
@@ -30,11 +32,10 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class AssetManager {
+ private static final Logger logger = LoggerFactory.getLogger(AssetManager.class);
private static AssetManager instance = null;
public static AssetManager getInstance() {
@@ -45,7 +46,6 @@ public static AssetManager getInstance() {
return instance;
}
- private Logger logger = Logger.getLogger(this.getClass().getCanonicalName());
private Map<String, AssetSource> assetSources = Maps.newHashMap();
private EnumMap<AssetType, Map<String, AssetLoader>> assetLoaders = Maps.newEnumMap(AssetType.class);
private Map<AssetUri, Asset> assetCache = Maps.newHashMap();
@@ -89,7 +89,7 @@ private Asset loadAsset(AssetUri uri, boolean logErrors) {
List<URL> urls = getAssetURLs(uri);
if (urls.size() == 0) {
if (logErrors) {
- logger.log(Level.WARNING, "Unable to resolve asset: " + uri);
+ logger.warn("Unable to resolve asset: {}", uri);
}
return null;
}
@@ -114,22 +114,22 @@ private Asset loadAsset(AssetUri uri, boolean logErrors) {
if (asset != null) {
assetCache.put(uri, asset);
}
- logger.log(Level.INFO, "Loaded " + uri);
+ logger.debug("Loaded {}", uri);
return asset;
} catch (IOException ioe) {
- logger.log(Level.SEVERE, "Error reading asset " + uri, ioe);
+ logger.error("Error reading asset {}", uri, ioe);
return null;
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException innerException) {
- logger.log(Level.SEVERE, "Error closing stream for " + uri, innerException);
+ logger.error("Error closing stream for {}", uri, innerException);
}
}
}
}
- logger.log(Level.WARNING, "Unable to resolve asset: " + uri);
+ logger.warn("Unable to resolve asset: {}", uri);
return null;
}
View
34 src/main/java/org/terasology/asset/AssetType.java
@@ -16,22 +16,19 @@
package org.terasology.asset;
-import java.util.Map;
-import java.util.logging.Logger;
-
+import com.google.common.collect.Maps;
+import org.terasology.asset.loaders.OggSoundLoader;
+import org.terasology.asset.loaders.OggStreamingSoundLoader;
import org.terasology.rendering.assetLoaders.GLSLShaderLoader;
import org.terasology.rendering.assetLoaders.MaterialLoader;
import org.terasology.rendering.assetLoaders.ObjMeshLoader;
-import org.terasology.asset.loaders.OggSoundLoader;
-import org.terasology.asset.loaders.OggStreamingSoundLoader;
import org.terasology.rendering.assetLoaders.PNGTextureLoader;
import org.terasology.rendering.assetLoaders.md5.MD5AnimationLoader;
import org.terasology.rendering.assetLoaders.md5.MD5SkeletonLoader;
import org.terasology.world.block.loader.TileLoader;
import org.terasology.world.block.shapes.JsonBlockShapeLoader;
-import com.google.common.collect.Maps;
-
+import java.util.Map;
/**
@@ -70,10 +67,9 @@ public AssetUri getUri(String sourceId, String item) {
ANIMATION("animation", "animations", "md5anim", new MD5AnimationLoader());
-
/* ============
- * Class fields
- * ============ */
+ * Class fields
+ * ============ */
private String typeId;
@@ -95,8 +91,6 @@ public AssetUri getUri(String sourceId, String item) {
*/
private AssetLoader assetLoader;
- private Logger logger = Logger.getLogger(getClass().getName());
-
static {
typeIdLookup = Maps.newHashMap();
subDirLookup = Maps.newHashMap();
@@ -108,10 +102,9 @@ public AssetUri getUri(String sourceId, String item) {
}
-
/* ==========
- * Public API
- * ========== */
+ * Public API
+ * ========== */
private AssetType(String typeId, String subDir, String fileExtension, AssetLoader assetLoader) {
this.typeId = typeId;
@@ -147,10 +140,9 @@ public AssetUri getUri(String sourceId, String item) {
}
-
/* ==========
- * Static API
- * ========== */
+ * Static API
+ * ========== */
public static AssetType getTypeForId(String id) {
return typeIdLookup.get(id);
@@ -165,9 +157,11 @@ public static AssetType getTypeForSubDir(String dir) {
* class associated with them.
*/
public static void registerAssetTypes() {
- for(AssetType type : AssetType.values()) {
+ for (AssetType type : AssetType.values()) {
AssetLoader loader = type.getAssetLoader();
- if(loader == null) continue; // No loader has been assigned to this AssetType
+ if (loader == null) {
+ continue; // No loader has been assigned to this AssetType
+ }
AssetManager.getInstance().register(
type,
View
13 src/main/java/org/terasology/asset/sources/AbstractSource.java
@@ -16,23 +16,20 @@
package org.terasology.asset.sources;
-import java.net.URL;
-import java.util.List;
-import java.util.logging.Logger;
-
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
import org.terasology.asset.AssetSource;
import org.terasology.asset.AssetType;
import org.terasology.asset.AssetUri;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
+import java.net.URL;
+import java.util.List;
/**
* @author Immortius
*/
public abstract class AbstractSource implements AssetSource {
- private Logger logger = Logger.getLogger(getClass().getName());
private String sourceId;
private Multimap<AssetUri, URL> assets = HashMultimap.create();
private Multimap<AssetType, AssetUri> assetsByType = HashMultimap.create();
View
18 src/main/java/org/terasology/asset/sources/ArchiveSource.java
@@ -16,24 +16,24 @@
package org.terasology.asset.sources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.terasology.asset.AssetUri;
+
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.JarFile;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import org.terasology.asset.AssetUri;
-
/**
* @author Immortius
*/
public class ArchiveSource extends AbstractSource {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private final Logger logger = LoggerFactory.getLogger(ArchiveSource.class);
private String basePath;
public ArchiveSource(String sourceId, File archive, String basePath) {
@@ -61,14 +61,16 @@ protected void scanArchive(File file) throws IOException {
while (lister.hasMoreElements()) {
ZipEntry entry = lister.nextElement();
String entryPath = entry.getName();
- logger.log(Level.INFO, "Found " + entryPath);
+ logger.debug("Found {}", entryPath);
if (entryPath.startsWith(basePath)) {
String key = entryPath.substring(basePath.length() + 1);
AssetUri uri = getUri(key);
- if (uri == null || !uri.isValid()) continue;
+ if (uri == null || !uri.isValid()) {
+ continue;
+ }
- logger.info("Discovered resource " + uri);
+ logger.debug("Discovered resource {}", uri);
// @todo avoid this risky approach
// Using a jar protocol for zip files, because cannot register new protocols for the applet
View
11 src/main/java/org/terasology/asset/sources/DirectorySource.java
@@ -16,19 +16,20 @@
package org.terasology.asset.sources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.terasology.asset.AssetUri;
+
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.util.logging.Logger;
-
-import org.terasology.asset.AssetUri;
/**
* @author Immortius
*/
public class DirectorySource extends AbstractSource {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(DirectorySource.class);
public DirectorySource(String id, File rootDirectory) {
super(id);
@@ -64,7 +65,7 @@ private void scanFiles(File file, String basePath) {
try {
addItem(uri, child.toURI().toURL());
} catch (MalformedURLException e) {
- logger.warning("Failed to load asset " + key + " - " + e.getMessage());
+ logger.warn("Failed to load asset {}", key, e.getMessage());
}
}
}
View
11 src/main/java/org/terasology/audio/OggStreamingSound.java
@@ -18,18 +18,19 @@
import java.io.IOException;
import java.net.URL;
import java.nio.ByteBuffer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.asset.AssetUri;
import org.terasology.utilities.OggReader;
public class OggStreamingSound extends AbstractStreamingSound {
+ private static final Logger logger = LoggerFactory.getLogger(OggStreamingSound.class);
private ByteBuffer dataBuffer = ByteBuffer.allocateDirect(4096 * 8);
private OggReader file = null;
- private Logger logger = Logger.getLogger(getClass().getName());
+
public OggStreamingSound(AssetUri uri, URL source) {
super(uri, source);
@@ -61,14 +62,14 @@ public void reset() {
try {
file.close();
} catch (IOException e) {
- logger.log(Level.WARNING, "Failed to close streaming sound: " + getURI(), e);
+ logger.warn("Failed to close streaming sound: {}", getURI(), e);
}
}
try {
file = new OggReader(audioSource.openStream());
} catch (IOException e) {
- logger.log(Level.SEVERE, "Failed to load streaming sound: " + getURI(), e);
+ logger.error("Failed to load streaming sound: {}", getURI(), e);
}
}
View
20 src/main/java/org/terasology/audio/OpenALManager.java
@@ -29,6 +29,8 @@
import org.lwjgl.openal.ALC11;
import org.lwjgl.openal.ALCcontext;
import org.lwjgl.openal.ALCdevice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.game.CoreRegistry;
import org.terasology.logic.LocalPlayer;
import org.terasology.logic.manager.AudioManager;
@@ -37,6 +39,8 @@
public class OpenALManager extends AudioManager {
+ private static final Logger logger = LoggerFactory.getLogger(OpenALManager.class);
+
/**
* For faster distance check *
*/
@@ -57,27 +61,27 @@ public void initialize() {
AL10.alGetError();
- logger.info("OpenAL " + AL10.alGetString(AL10.AL_VERSION) + " initialized!");
+ logger.info("OpenAL {} initialized!", AL10.alGetString(AL10.AL_VERSION));
ALCcontext context = ALC10.alcGetCurrentContext();
ALCdevice device = ALC10.alcGetContextsDevice(context);
- logger.info("Using OpenAL: " + AL10.alGetString(AL10.AL_RENDERER) + " by " + AL10.alGetString(AL10.AL_VENDOR));
- logger.info("Using device: " + ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER));
- logger.info("Available AL extensions: " + AL10.alGetString(AL10.AL_EXTENSIONS));
- logger.info("Available ALC extensions: " + ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS));
+ logger.info("Using OpenAL: {} by {}", AL10.alGetString(AL10.AL_RENDERER), AL10.alGetString(AL10.AL_VENDOR));
+ logger.info("Using device: {}", ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER));
+ logger.info("Available AL extensions: {}", AL10.alGetString(AL10.AL_EXTENSIONS));
+ logger.info("Available ALC extensions: {}", ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS));
IntBuffer buffer = BufferUtils.createIntBuffer(1);
ALC10.alcGetInteger(device, ALC11.ALC_MONO_SOURCES, buffer);
- logger.info("Max mono sources: " + buffer.get(0));
+ logger.info("Max mono sources: {}", buffer.get(0));
buffer.rewind();
ALC10.alcGetInteger(device, ALC11.ALC_STEREO_SOURCES, buffer);
- logger.info("Max stereo sources: " + buffer.get(0));
+ logger.info("Max stereo sources: {}", buffer.get(0));
buffer.rewind();
ALC10.alcGetInteger(device, ALC10.ALC_FREQUENCY, buffer);
- logger.info("Mixer frequency: " + buffer.get(0));
+ logger.info("Mixer frequency: {}", buffer.get(0));
buffer.rewind();
AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);
View
10 src/main/java/org/terasology/componentSystem/worldSimulation/GrowthSimulator.java
@@ -21,9 +21,9 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.world.block.BlockComponent;
import org.terasology.entitySystem.EntityRef;
import org.terasology.entitySystem.EventHandlerSystem;
@@ -47,7 +47,7 @@
@RegisterComponentSystem
public class GrowthSimulator implements EventHandlerSystem {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(GrowthSimulator.class);
private WorldProvider world;
private Block air;
@@ -81,7 +81,7 @@ public void run() {
}
}
} catch (InterruptedException e) {
- logger.log(Level.INFO, "Interrupted");
+ logger.error("Thread Interrupted", e);
}
}
}
@@ -95,7 +95,7 @@ public void shutdown() {
try {
executor.awaitTermination(1, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
- logger.log(Level.SEVERE, "Interrupted awaiting shutdown");
+ logger.error("Interrupted awaiting shutdown", e);
}
if (blockQueue.isEmpty()) {
executor.shutdownNow();
View
8 src/main/java/org/terasology/config/Config.java
@@ -18,6 +18,8 @@
import com.google.common.collect.Multimap;
import com.google.gson.GsonBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.input.Input;
import org.terasology.logic.manager.PathManager;
import org.terasology.utilities.gson.InputHandler;
@@ -27,8 +29,6 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Terasology user config. Holds the various global configuration information that the user can modify. It can be saved
@@ -37,7 +37,7 @@
* @author Immortius
*/
public final class Config {
- private static Logger logger = Logger.getLogger(Config.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(Config.class);
private InputConfig input = new InputConfig();
/**
@@ -60,7 +60,7 @@ public void save() {
try {
save(getConfigFile(), this);
} catch (IOException e) {
- logger.log(Level.SEVERE, "Failed to save config", e);
+ logger.error("Failed to save config", e);
}
}
View
22 src/main/java/org/terasology/entitySystem/metadata/ComponentLibraryImpl.java
@@ -24,9 +24,9 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.Component;
import org.terasology.entitySystem.metadata.core.BooleanTypeHandler;
import org.terasology.entitySystem.metadata.core.ByteTypeHandler;
@@ -48,8 +48,8 @@
*/
public final class ComponentLibraryImpl implements ComponentLibrary {
private static final int MAX_SERIALIZATION_DEPTH = 1;
+ private static final Logger logger = LoggerFactory.getLogger(ComponentLibraryImpl.class);
- private Logger logger = Logger.getLogger(getClass().getName());
private Map<Class<? extends Component>, ComponentMetadata> componentSerializationLookup = Maps.newHashMap();
private Map<String, Class<? extends Component>> componentTypeLookup = Maps.newHashMap();
private Map<Class<?>, TypeHandler<?>> typeHandlers = Maps.newHashMap();
@@ -80,7 +80,7 @@ public ComponentLibraryImpl() {
// Check if constructor exists
componentClass.getConstructor();
} catch (NoSuchMethodException e) {
- logger.log(Level.SEVERE, String.format("Unable to register component class %s: Default Constructor Required", componentClass.getSimpleName()));
+ logger.error("Unable to register component class {}: Default Constructor Required", componentClass.getSimpleName());
return;
}
@@ -91,7 +91,7 @@ public ComponentLibraryImpl() {
field.setAccessible(true);
TypeHandler typeHandler = getHandlerFor(field.getGenericType(), 0);
if (typeHandler == null) {
- logger.log(Level.SEVERE, "Unsupported field type in component type " + componentClass.getSimpleName() + ", " + field.getName() + " : " + field.getGenericType());
+ logger.error("Unsupported field type in component type {}, {} : {}", componentClass.getSimpleName(), field.getName(), field.getGenericType());
} else {
info.addField(new FieldMetadata(field, componentClass, typeHandler));
}
@@ -137,7 +137,7 @@ private TypeHandler getHandlerFor(Type type, int depth) {
} else if (type instanceof ParameterizedType) {
typeClass = (Class) ((ParameterizedType) type).getRawType();
} else {
- logger.log(Level.SEVERE, "Cannot obtain class for type " + type);
+ logger.error("Cannot obtain class for type {}", type);
return null;
}
@@ -153,7 +153,7 @@ else if (List.class.isAssignableFrom(typeClass)) {
return new ListTypeHandler(innerHandler);
}
}
- logger.log(Level.SEVERE, "List field is not parameterized, or holds unsupported type");
+ logger.error("List field is not parameterized, or holds unsupported type");
return null;
}
// For Maps, createEntityRef the handler for the value type (and maybe key too?)
@@ -168,7 +168,7 @@ else if (Map.class.isAssignableFrom(typeClass)) {
}
}
}
- logger.log(Level.SEVERE, "Map field is not parameterized, does not have a String key, or holds unsupported values");
+ logger.error("Map field is not parameterized, does not have a String key, or holds unsupported values");
}
// For know types, just use the handler
else if (typeHandlers.containsKey(typeClass)) {
@@ -181,11 +181,11 @@ else if (depth <= MAX_SERIALIZATION_DEPTH && !Modifier.isAbstract(typeClass.getM
Constructor constructor = typeClass.getConstructor();
} catch (NoSuchMethodException e) {
- logger.log(Level.SEVERE, String.format("Unable to register field of type %s: no publicly accessible default constructor", typeClass.getSimpleName()));
+ logger.error("Unable to register field of type {}: no publicly accessible default constructor", typeClass.getSimpleName());
return null;
}
- logger.log(Level.WARNING, "Handling serialization of type " + typeClass + " via MappedContainer");
+ logger.warn("Handling serialization of type {} via MappedContainer", typeClass);
MappedContainerTypeHandler mappedHandler = new MappedContainerTypeHandler(typeClass);
for (Field field : typeClass.getDeclaredFields()) {
if (Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers()))
@@ -194,7 +194,7 @@ else if (depth <= MAX_SERIALIZATION_DEPTH && !Modifier.isAbstract(typeClass.getM
field.setAccessible(true);
TypeHandler handler = getHandlerFor(field.getGenericType(), depth + 1);
if (handler == null) {
- logger.log(Level.SEVERE, "Unsupported field type in component type " + typeClass.getSimpleName() + ", " + field.getName() + " : " + field.getGenericType());
+ logger.error("Unsupported field type in component type {}, {} : {}", typeClass.getSimpleName(), field.getName(), field.getGenericType());
} else {
mappedHandler.addField(new FieldMetadata(field, typeClass, handler));
}
View
16 src/main/java/org/terasology/entitySystem/metadata/ComponentMetadata.java
@@ -18,9 +18,9 @@
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.Component;
import com.google.common.collect.Maps;
@@ -29,7 +29,7 @@
* @author Immortius <immortius@gmail.com>
*/
public final class ComponentMetadata<T extends Component> {
- private static final Logger logger = Logger.getLogger(ComponentMetadata.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(ComponentMetadata.class);
private Map<String, FieldMetadata> fields = Maps.newHashMap();
private Class<T> clazz;
@@ -58,9 +58,9 @@ public T newInstance() {
try {
return clazz.newInstance();
} catch (InstantiationException e) {
- logger.log(Level.SEVERE, "Exception instantiating component type: " + clazz, e);
+ logger.error("Exception instantiating component type: {}", clazz, e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Exception instantiating component type: " + clazz, e);
+ logger.error("Exception instantiating component type: {}", clazz, e);
}
return null;
}
@@ -73,11 +73,11 @@ public T clone(T component) {
}
return result;
} catch (InstantiationException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + clazz, e);
+ logger.error("Exception during serializing component type: {}", clazz, e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + clazz, e);
+ logger.error("Exception during serializing component type: {}", clazz, e);
} catch (InvocationTargetException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + clazz, e);
+ logger.error("Exception during serializing component type: {}", clazz, e);
}
return null;
}
View
21 src/main/java/org/terasology/entitySystem/metadata/core/EnumTypeHandler.java
@@ -16,9 +16,9 @@
package org.terasology.entitySystem.metadata.core;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.components.ItemComponent;
import org.terasology.entitySystem.metadata.TypeHandler;
import org.terasology.protobuf.EntityData;
@@ -29,8 +29,9 @@
* @author Immortius <immortius@gmail.com>
*/
public class EnumTypeHandler<T extends Enum> implements TypeHandler<T> {
+
+ private static final Logger logger = LoggerFactory.getLogger(EnumTypeHandler.class);
private Class<T> enumType;
- private Logger logger = Logger.getLogger(getClass().getName());
public EnumTypeHandler(Class<T> enumType) {
this.enumType = enumType;
@@ -46,17 +47,7 @@ public T deserialize(EntityData.Value value) {
Enum resultValue = Enum.valueOf(enumType, value.getString(0));
return enumType.cast(resultValue);
} catch (IllegalArgumentException iae) {
- // TODO: Temp code due to changed enum case, remove after next milestone
- if (enumType == ItemComponent.UsageType.class) {
- if (value.equals("OnUser")) {
- return enumType.cast(ItemComponent.UsageType.ON_USER);
- } else if (value.equals("OnBlock")) {
- return enumType.cast(ItemComponent.UsageType.ON_BLOCK);
- } else if (value.equals("InDirection")) {
- return enumType.cast(ItemComponent.UsageType.IN_DIRECTION);
- }
- }
- logger.log(Level.WARNING, "Unable to deserialize enum: ", iae);
+ logger.warn("Unable to deserialize enum {}", enumType, iae);
}
}
return null;
@@ -81,7 +72,7 @@ public T copy(T value) {
Enum resultValue = Enum.valueOf(enumType, item);
result.add(enumType.cast(resultValue));
} catch (IllegalArgumentException iae) {
- logger.log(Level.WARNING, "Unable to deserialize enum: ", iae);
+ logger.warn("Unable to deserialize enum {}", enumType, iae);
}
}
return result;
View
18 src/main/java/org/terasology/entitySystem/metadata/core/MappedContainerTypeHandler.java
@@ -18,9 +18,9 @@
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.metadata.AbstractTypeHandler;
import org.terasology.entitySystem.metadata.FieldMetadata;
import org.terasology.protobuf.EntityData;
@@ -32,7 +32,7 @@
*/
public class MappedContainerTypeHandler<T> extends AbstractTypeHandler<T> {
- private static Logger logger = Logger.getLogger(MappedContainerTypeHandler.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(MappedContainerTypeHandler.class);
private Class<T> clazz;
private Map<String, FieldMetadata> fields = Maps.newHashMap();
@@ -62,9 +62,9 @@ public void addField(FieldMetadata info) {
}
}
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Unable to serialize field of " + value.getClass(), e);
+ logger.error("Unable to serialize field of {}", value.getClass(), e);
} catch (InvocationTargetException e) {
- logger.log(Level.SEVERE, "Unable to serialize field of " + value.getClass(), e);
+ logger.error("Unable to serialize field of {}", value.getClass(), e);
}
return result.build();
}
@@ -83,7 +83,7 @@ public T deserialize(EntityData.Value value) {
}
return result;
} catch (Exception e) {
- logger.log(Level.SEVERE, "Unable to deserialize " + value, e);
+ logger.error("Unable to deserialize {}", value, e);
}
return null;
}
@@ -97,11 +97,11 @@ public T copy(T value) {
}
return result;
} catch (InstantiationException e) {
- logger.log(Level.SEVERE, "Unable to clone " + value.getClass(), e);
+ logger.error("Unable to clone {}", value.getClass(), e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Unable to clone " + value.getClass(), e);
+ logger.error("Unable to clone {}", value.getClass(), e);
} catch (InvocationTargetException e) {
- logger.log(Level.SEVERE, "Unable to clone " + value.getClass(), e);
+ logger.error("Unable to clone {}", value.getClass(), e);
}
}
return null;
View
38 src/main/java/org/terasology/entitySystem/persistence/EntityPersisterHelperImpl.java
@@ -27,9 +27,9 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.Component;
import org.terasology.entitySystem.EntityInfoComponent;
import org.terasology.entitySystem.EntityRef;
@@ -50,7 +50,7 @@
* @author Immortius <immortius@gmail.com>
*/
public class EntityPersisterHelperImpl implements EntityPersisterHelper {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(EntityPersisterHelperImpl.class);
private ComponentLibrary componentLibrary;
private PrefabManager prefabManager;
@@ -128,7 +128,7 @@ public EntityPersisterHelperImpl(PersistableEntityManager entityManager) {
public EntityData.Component serializeComponent(Component component) {
ComponentMetadata<?> componentMetadata = componentLibrary.getMetadata(component.getClass());
if (componentMetadata == null) {
- logger.log(Level.SEVERE, "Unregistered component type: " + component.getClass());
+ logger.error("Unregistered component type: {}", component.getClass());
return null;
}
EntityData.Component.Builder componentMessage = EntityData.Component.newBuilder();
@@ -148,9 +148,9 @@ public EntityPersisterHelperImpl(PersistableEntityManager entityManager) {
componentMessage.addField(EntityData.NameValue.newBuilder().setName(field.getName()).setValue(value).build());
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + component.getClass(), e);
+ logger.error("Exception during serializing component type: {}", component.getClass(), e);
} catch (InvocationTargetException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + component.getClass(), e);
+ logger.error("Exception during serializing component type: {}", component.getClass(), e);
}
}
@@ -231,7 +231,7 @@ public Prefab deserializePrefab(EntityData.Prefab prefabData, String packageCont
Prefab parent = prefabManager.getPrefab(parentName);
if (parent == null) {
- logger.log(Level.SEVERE, "Missing parent prefab (need to fix parent serialization)");
+ logger.error("Missing parent prefab (need to fix parent serialization)");
} else {
prefab.addParent(parent);
}
@@ -253,7 +253,7 @@ public Prefab deserializePrefab(EntityData.Prefab prefabData) {
for (String parentName : prefabData.getParentNameList()) {
Prefab parent = prefabManager.getPrefab(parentName);
if (parent == null) {
- logger.log(Level.SEVERE, "Missing parent prefab (need to fix parent serialization)");
+ logger.error("Missing parent prefab (need to fix parent serialization)");
} else {
prefab.addParent(parent);
}
@@ -275,7 +275,7 @@ public Component deserializeComponent(EntityData.Component componentData) {
Component component = componentMetadata.newInstance();
return deserializeOnto(component, componentData, componentMetadata);
} else {
- logger.log(Level.WARNING, "Unable to deserialise unknown component type: " + componentData.getType());
+ logger.warn("Unable to deserialise unknown component type: {}", componentData.getType());
}
return null;
}
@@ -359,19 +359,19 @@ public boolean execute(int i) {
if (componentData.hasTypeIndex()) {
ComponentMetadata metadata = componentLibrary.getMetadata(componentIdTable.get(componentData.getTypeIndex()));
if (metadata == null) {
- logger.log(Level.WARNING, "Unable to deserialise unknown component with id: " + componentData.getTypeIndex());
+ logger.warn("Unable to deserialise unknown component with id: {}", componentData.getTypeIndex());
return null;
}
return metadata.getType();
} else if (componentData.hasType()) {
ComponentMetadata metadata = componentLibrary.getMetadata(componentData.getType().toLowerCase(Locale.ENGLISH));
if (metadata == null) {
- logger.log(Level.WARNING, "Unable to deserialise unknown component type: " + componentData.getType());
+ logger.warn("Unable to deserialise unknown component type: {}", componentData.getType());
return null;
}
return metadata.getType();
}
- logger.log(Level.WARNING, "Unable to deserialise component, no type provided.");
+ logger.warn("Unable to deserialise component, no type provided.");
return null;
}
@@ -422,7 +422,7 @@ public boolean execute(int i) {
private EntityData.Component serializeComponent(Component base, Component delta) {
ComponentMetadata<?> componentMetadata = componentLibrary.getMetadata(base.getClass());
if (componentMetadata == null) {
- logger.log(Level.SEVERE, "Unregistered component type: " + base.getClass());
+ logger.error("Unregistered component type: {}", base.getClass());
return null;
}
@@ -445,13 +445,13 @@ public boolean execute(int i) {
componentMessage.addField(EntityData.NameValue.newBuilder().setName(field.getName()).setValue(value).build());
changed = true;
} else {
- logger.log(Level.SEVERE, "Exception serializing component type: " + base.getClass() + ", field: " + field.getName() + " - returned null");
+ logger.error("Exception serializing component type: {}, field: {} - returned null", base.getClass(), field.getName());
}
}
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + base.getClass(), e);
+ logger.error("Exception during serializing component type: {}", base.getClass(), e);
} catch (InvocationTargetException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + base.getClass(), e);
+ logger.error("Exception during serializing component type: {}", base.getClass(), e);
}
}
if (changed) {
@@ -466,7 +466,7 @@ private Component deserializeComponentOnto(Component component, EntityData.Compo
ComponentMetadata componentMetadata = componentLibrary.getMetadata(componentClass);
return deserializeOnto(component, componentData, componentMetadata);
} else {
- logger.log(Level.WARNING, "Unable to deserialise unknown component type: " + componentData.getType());
+ logger.warn("Unable to deserialise unknown component type: {}", componentData.getType());
}
return null;
}
@@ -485,9 +485,9 @@ private Component deserializeOnto(Component component, EntityData.Component comp
}
return component;
} catch (InvocationTargetException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + component.getClass(), e);
+ logger.error("Exception during serializing component type: {}", component.getClass(), e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Exception during serializing component type: " + component.getClass(), e);
+ logger.error("Exception during serializing component type: {}", component.getClass(), e);
}
return null;
}
View
14 src/main/java/org/terasology/entitySystem/persistence/WorldPersister.java
@@ -25,9 +25,9 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.EntityManager;
import org.terasology.entitySystem.PersistableEntityManager;
import org.terasology.protobuf.EntityData;
@@ -88,7 +88,7 @@ void save(OutputStream out, EntityData.World world) throws IOException {
abstract EntityData.World load(InputStream in) throws IOException;
}
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(WorldPersister.class);
private EntityManager entityManager;
private EntityPersisterHelper persisterHelper;
@@ -102,7 +102,9 @@ public void save(File file, SaveFormat format) throws IOException {
File parentFile = file.getParentFile();
if (parentFile != null) {
- parentFile.mkdirs();
+ if (!parentFile.mkdirs()) {
+ logger.error("Failed to create world save directory {}", parentFile);
+ }
}
FileOutputStream out = new FileOutputStream(file);
@@ -113,7 +115,7 @@ public void save(File file, SaveFormat format) throws IOException {
try {
out.close();
} catch (IOException e) {
- logger.log(Level.SEVERE, "Failed to close file", e);
+ logger.error("Failed to close file", e);
}
}
}
@@ -130,7 +132,7 @@ public void load(File file, SaveFormat format) throws IOException {
try {
in.close();
} catch (IOException e) {
- logger.log(Level.SEVERE, "Failed to close file", e);
+ logger.error("Failed to close file", e);
}
}
View
8 src/main/java/org/terasology/entitySystem/pojo/PojoEntityManager.java
@@ -26,12 +26,12 @@
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3f;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.components.world.LocationComponent;
import org.terasology.entitySystem.Component;
import org.terasology.entitySystem.EntityInfoComponent;
@@ -59,7 +59,7 @@
public class PojoEntityManager implements EntityManager, PersistableEntityManager {
public static final int NULL_ID = 0;
- private static Logger logger = Logger.getLogger(PojoEntityManager.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(PojoEntityManager.class);
private int nextEntityId = 1;
private TIntList freedIds = new TIntArrayList();
@@ -116,7 +116,7 @@ public EntityRef create(String prefabName) {
if (prefabName != null && !prefabName.isEmpty()) {
Prefab prefab = prefabManager.getPrefab(prefabName);
if (prefab == null) {
- logger.log(Level.WARNING, "Unable to instantiate unknown prefab: \"" + prefabName + "\"");
+ logger.warn("Unable to instantiate unknown prefab: \"{}\"", prefabName);
return EntityRef.NULL;
}
return create(prefab);
View
18 src/main/java/org/terasology/entitySystem/pojo/PojoEventSystem.java
@@ -25,10 +25,10 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.reflections.Reflections;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.AbstractEvent;
import org.terasology.entitySystem.Component;
import org.terasology.entitySystem.EntityManager;
@@ -55,7 +55,7 @@
*/
public class PojoEventSystem implements EventSystem {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(PojoEventSystem.class);
private EntityManager entitySystem;
private Map<Class<? extends Event>, Multimap<Class<? extends Component>, EventHandlerInfo>> componentSpecificHandlers = Maps.newHashMap();
@@ -88,7 +88,7 @@ public void registerEvent(String name, Class<? extends Event> eventType) {
if (name != null && !name.isEmpty()) {
eventIdMap.put(name, eventType);
}
- logger.fine("Registering event " + eventType.getSimpleName());
+ logger.debug("Registering event {}", eventType.getSimpleName());
for (Class parent : Reflections.getAllSuperTypes(eventType, Predicates.assignableFrom(Event.class))) {
if (!AbstractEvent.class.equals(parent) && !Event.class.equals(parent)) {
childEvents.put(parent, eventType);
@@ -101,7 +101,7 @@ public void registerEventHandler(EventHandlerSystem handler) {
Class handlerClass = handler.getClass();
// TODO: Support private methods
if (!Modifier.isPublic(handlerClass.getModifiers())) {
- logger.warning(String.format("Cannot register handler %s, must be public", handler.getClass().getName()));
+ logger.error("Cannot register handler {}, must be public", handler.getClass().getName());
return;
}
@@ -124,7 +124,7 @@ public void registerEventHandler(EventHandlerSystem handler) {
}
}
} else {
- logger.warning("Invalid event handler method: " + method.getName());
+ logger.error("Invalid event handler method: {}", method.getName());
}
}
}
@@ -252,11 +252,11 @@ public void invoke(EntityRef entity, Event event) {
try {
method.invoke(handler, event, entity);
} catch (IllegalAccessException ex) {
- logger.log(Level.SEVERE, "Failed to invoke event", ex);
+ logger.error("Failed to invoke event", ex);
} catch (IllegalArgumentException ex) {
- logger.log(Level.SEVERE, "Failed to invoke event", ex);
+ logger.error("Failed to invoke event", ex);
} catch (InvocationTargetException ex) {
- logger.log(Level.SEVERE, "Failed to invoke event", ex);
+ logger.error("Failed to invoke event", ex);
}
}
View
30 src/main/java/org/terasology/game/ComponentSystemManager.java
@@ -15,17 +15,11 @@
*/
package org.terasology.game;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import org.reflections.Reflections;
-import org.reflections.scanners.Scanner;
-import org.reflections.scanners.TypeAnnotationsScanner;
-import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.componentSystem.RenderSystem;
import org.terasology.componentSystem.UpdateSubscriberSystem;
import org.terasology.entitySystem.ComponentSystem;
@@ -33,9 +27,9 @@
import org.terasology.entitySystem.EventHandlerSystem;
import org.terasology.entitySystem.RegisterComponentSystem;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.terasology.logic.mod.Mod;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Simple manager for component systems.
@@ -45,7 +39,7 @@
*/
public class ComponentSystemManager {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(ComponentSystemManager.class);
private Map<String, ComponentSystem> namedLookup = Maps.newHashMap();
private List<UpdateSubscriberSystem> updateSubscribers = Lists.newArrayList();
@@ -59,7 +53,7 @@ public void loadSystems(String packageName, Reflections reflections) {
Set<Class<?>> systems = reflections.getTypesAnnotatedWith(RegisterComponentSystem.class);
for (Class<?> system : systems) {
if (!ComponentSystem.class.isAssignableFrom(system)) {
- logger.log(Level.WARNING, String.format("Cannot load %s, must be a subclass of ComponentSystem", system.getSimpleName()));
+ logger.error("Cannot load {}, must be a subclass of ComponentSystem", system.getSimpleName());
continue;
}
@@ -69,11 +63,11 @@ public void loadSystems(String packageName, Reflections reflections) {
try {
ComponentSystem newSystem = (ComponentSystem) system.newInstance();
register(newSystem, id);
- logger.log(Level.INFO, "Loaded " + id);
+ logger.debug("Loaded system {}", id);
} catch (InstantiationException e) {
- logger.log(Level.SEVERE, "Failed to load system " + id, e);
+ logger.error("Failed to load system {}", id, e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Failed to load system " + id, e);
+ logger.error("Failed to load system {}", id, e);
}
}
View
9 src/main/java/org/terasology/game/Terasology.java
@@ -15,9 +15,8 @@
*/
package org.terasology.game;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.game.modes.StateMainMenu;
import org.terasology.logic.manager.PathManager;
@@ -32,7 +31,7 @@
public final class Terasology {
private static TerasologyEngine engine = new TerasologyEngine();
- private final static Logger logger = Logger.getLogger("Terasology");
+ private static final Logger logger = LoggerFactory.getLogger(Terasology.class);
private Terasology() {
}
@@ -44,7 +43,7 @@ public static void main(String[] args) {
engine.run(new StateMainMenu());
engine.dispose();
} catch (Throwable t) {
- Logger.getLogger(Terasology.class.getName()).log(Level.SEVERE, "Uncaught Exception", t);
+ logger.error("Uncaught Exception", t);
}
System.exit(0);
}
View
15 src/main/java/org/terasology/game/TerasologyApplet.java
@@ -24,9 +24,9 @@
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.game.modes.StateMainMenu;
import org.terasology.logic.manager.PathManager;
@@ -36,6 +36,7 @@
*/
@SuppressWarnings("serial")
public final class TerasologyApplet extends Applet {
+ private static final Logger logger = LoggerFactory.getLogger(TerasologyApplet.class);
private TerasologyEngine engine;
private Thread gameThread;
@@ -62,11 +63,11 @@ private void obtainMods() {
}
fos.close();
} catch (MalformedURLException e) {
- Logger.getLogger(TerasologyApplet.class.getName()).log(Level.SEVERE, "Unable to obtain mod '" + mod + "'", e);
+ logger.error("Unable to obtain mod '{}'", mod, e);
} catch (FileNotFoundException e) {
- Logger.getLogger(TerasologyApplet.class.getName()).log(Level.SEVERE, "Unable to obtain mod '" + mod + "'", e);
+ logger.error("Unable to obtain mod '{}'", mod, e);
} catch (IOException e) {
- Logger.getLogger(TerasologyApplet.class.getName()).log(Level.SEVERE, "Unable to obtain mod '" + mod + "'", e);
+ logger.error("Unable to obtain mod '{}'", mod, e);
}
}
}
@@ -80,7 +81,7 @@ public void run() {
engine.run(new StateMainMenu());
engine.dispose();
} catch (Exception e) {
- Logger.getLogger(TerasologyApplet.class.getName()).log(Level.SEVERE, e.toString(), e);
+ logger.error(e.toString(), e);
}
}
};
@@ -105,7 +106,7 @@ public void destroy() {
try {
gameThread.join();
} catch (InterruptedException e) {
- Logger.getLogger(getClass().getName()).severe("Failed to cleanly shut down engine");
+ logger.error("Failed to cleanly shut down engine");
}
super.destroy();
View
90 src/main/java/org/terasology/game/TerasologyEngine.java
@@ -23,6 +23,8 @@
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GLContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.asset.AssetManager;
import org.terasology.asset.AssetType;
import org.terasology.asset.sources.ClasspathSource;
@@ -44,10 +46,15 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.lang.reflect.Field;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.Deque;
import java.util.List;
import java.util.concurrent.Executors;
@@ -55,9 +62,9 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.FileHandler;
+import java.util.logging.Formatter;
import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.logging.SimpleFormatter;
+import java.util.logging.LogRecord;
import static org.lwjgl.opengl.GL11.GL_CULL_FACE;
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
@@ -72,7 +79,7 @@
*/
public class TerasologyEngine implements GameEngine {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(TerasologyEngine.class);
private Deque<GameState> stateStack = new ArrayDeque<GameState>();
private boolean initialised;
@@ -92,8 +99,9 @@ public void init() {
return;
}
initLogger();
- logger.log(Level.INFO, "Initializing Terasology...");
- logger.log(Level.INFO, TerasologyVersion.getInstance().toString());
+
+ logger.info("Initializing Terasology...");
+ logger.info(TerasologyVersion.getInstance().toString());
initConfig();
@@ -125,7 +133,7 @@ private void initConfig() {
config = org.terasology.config.Config.load(org.terasology.config.Config.getConfigFile());
} catch (IOException e) {
- logger.log(Level.SEVERE, "Failed to load config", e);
+ logger.error("Failed to load config", e);
config = new org.terasology.config.Config();
}
CoreRegistry.put(org.terasology.config.Config.class, config);
@@ -143,15 +151,19 @@ private void updateInputConfig() {
private void initLogger() {
if (LWJGLUtil.DEBUG) {
System.setOut(new PrintStream(System.out) {
+ private Logger logger = LoggerFactory.getLogger("org.lwjgl");
+
@Override
public void print(final String message) {
- Logger.getLogger("").info(message);
+ logger.info(message);
}
});
System.setErr(new PrintStream(System.err) {
+ private Logger logger = LoggerFactory.getLogger("org.lwjgl");
+
@Override
public void print(final String message) {
- Logger.getLogger("").severe(message);
+ logger.error(message);
}
});
}
@@ -164,12 +176,50 @@ public void print(final String message) {
}
try {
+ java.util.logging.Logger.getLogger("").getHandlers()[0].setLevel(Level.FINE);
+ java.util.logging.Logger.getLogger("").getHandlers()[0].setFormatter(new Formatter() {
+ DateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+
+ @Override
+ public String format(LogRecord record) {
+ String thrownMessage = "";
+ if (record.getThrown() != null) {
+ try {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ record.getThrown().printStackTrace(pw);
+ pw.close();
+ thrownMessage = sw.toString();
+ } catch (Exception ex) {
+ }
+ }
+ return String.format("[%s] (%s)\t%s:%s() - %s (Thread: %d)\n%s", record.getLevel().getLocalizedName(), dateFormat.format(new Date(record.getMillis())), record.getLoggerName(), record.getSourceMethodName(), formatMessage(record), record.getThreadID(), thrownMessage);
+ }
+ });
FileHandler fh = new FileHandler(new File(dirPath, "Terasology.log").getAbsolutePath(), false);
fh.setLevel(Level.INFO);
- fh.setFormatter(new SimpleFormatter());
- Logger.getLogger("").addHandler(fh);
+ fh.setFormatter(new Formatter() {
+ DateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+
+ @Override
+ public String format(LogRecord record) {
+ String thrownMessage = "";
+ if (record.getThrown() != null) {
+ try {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ record.getThrown().printStackTrace(pw);
+ pw.close();
+ thrownMessage = sw.toString();
+ } catch (Exception ex) {
+ }
+ }
+ return String.format("[%s] (%s)\t%s - %s\n%s", record.getLevel().getLocalizedName(), dateFormat.format(new Date(record.getMillis())), record.getLoggerName(), record.getSourceMethodName(), formatMessage(record), thrownMessage);
+ }
+ });
+ java.util.logging.Logger.getLogger("").addHandler(fh);
} catch (IOException ex) {
- logger.log(Level.WARNING, ex.toString(), ex);
+ logger.error("Failed to set up logging to file", ex);
}
}
@@ -253,7 +303,7 @@ public void run() {
try {
task.run();
} catch (RejectedExecutionException e) {
- logger.log(Level.SEVERE, "Thread submitted after shutdown requested: " + name);
+ logger.error("Thread submitted after shutdown requested: {}", name);
} finally {
PerformanceMonitor.endThread(name);
}
@@ -289,7 +339,7 @@ private void initNativeLibs() {
}
break;
default:
- logger.log(Level.SEVERE, "Unsupported operating system: " + LWJGLUtil.getPlatformName());
+ logger.error("Unsupported operating system: {}", LWJGLUtil.getPlatformName());
System.exit(1);
}
}
@@ -316,7 +366,7 @@ private void addLibraryPath(File libPath) {
usrPathsField.set(null, paths.toArray(new String[paths.size()]));
} catch (Exception e) {
- logger.log(Level.SEVERE, "Couldn't link static libraries. " + e.toString(), e);
+ logger.error("Couldn't link static libraries. ", e);
System.exit(1);
}
}
@@ -339,7 +389,7 @@ private void initDisplay() {
Display.setTitle("Terasology" + " | " + "Pre Alpha");
Display.create(Config.getInstance().getPixelFormat());
} catch (LWJGLException e) {
- logger.log(Level.SEVERE, "Can not initialize graphics device.", e);
+ logger.error("Can not initialize graphics device.", e);
System.exit(1);
}
}
@@ -358,7 +408,7 @@ private void checkOpenGL() {
& GLContext.getCapabilities().OpenGL15;
if (!canRunGame) {
- logger.log(Level.SEVERE, "Your GPU driver is not supporting the mandatory versions of OpenGL. Considered updating your GPU drivers?");
+ logger.error("Your GPU driver is not supporting the mandatory versions of OpenGL. Considered updating your GPU drivers?");
System.exit(1);
}
@@ -382,7 +432,7 @@ private void initControls() {
Mouse.create();
Mouse.setGrabbed(true);
} catch (LWJGLException e) {
- logger.log(Level.SEVERE, "Could not initialize controls.", e);
+ logger.error("Could not initialize controls.", e);
System.exit(1);
}
}
@@ -405,7 +455,7 @@ private void initTimer() {
}
private void cleanup() {
- logger.log(Level.INFO, "Shutting down Terasology...");
+ logger.info("Shutting down Terasology...");
Config.getInstance().saveConfig(new File(PathManager.getInstance().getWorldPath(), "last.cfg"));
doPurgeStates();
terminateThreads();
@@ -416,7 +466,7 @@ private void terminateThreads() {
try {
threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
- logger.log(Level.SEVERE, e.toString(), e);
+ logger.error("Error terminating thread pool.", e);
}
}
@@ -432,7 +482,7 @@ private void mainLoop() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
- logger.log(Level.WARNING, e.toString(), e);
+ logger.warn("Display inactivity sleep interrupted", e);
}
Display.processMessages();
View
36 src/main/java/org/terasology/game/modes/StateSinglePlayer.java
@@ -20,6 +20,8 @@
import org.reflections.Reflections;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.util.ConfigurationBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.asset.AssetManager;
import org.terasology.asset.AssetType;
import org.terasology.asset.AssetUri;
@@ -90,8 +92,6 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
@@ -108,7 +108,7 @@
public class StateSinglePlayer implements GameState {
public static final String ENTITY_DATA_FILE = "entity.dat";
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(StateSinglePlayer.class);
private WorldInfo worldInfo;
@@ -209,24 +209,24 @@ private void registerAxisBinds(String packageName, Iterable<Class<?>> classes) {
BindableButton positiveButton = inputSystem.getBindButton(info.positiveButton());
BindableButton negativeButton = inputSystem.getBindButton(info.negativeButton());
if (positiveButton == null) {
- logger.log(Level.WARNING, "Failed to register axis \"" + id + "\", missing positive button \"" + info.positiveButton() + "\"");
+ logger.warn("Failed to register axis \"{}\", missing positive button \"{}\"", id, info.positiveButton());
continue;
}
if (negativeButton == null) {
- logger.log(Level.WARNING, "Failed to register axis \"" + id + "\", missing negative button \"" + info.negativeButton() + "\"");
+ logger.warn("Failed to register axis \"{}\", missing negative button \"{}\"", id, info.negativeButton());
continue;
}
try {
BindableAxis bindAxis = inputSystem.registerBindAxis(id, (BindAxisEvent)registerBindClass.newInstance(), positiveButton, negativeButton);
bindAxis.setSendEventMode(info.eventMode());
- logger.log(Level.INFO, "Registered axis bind: " + id);
+ logger.debug("Registered axis bind: {}", id);
} catch (InstantiationException e) {
- logger.log(Level.SEVERE, "Failed to register axis bind \"" + id + "\"", e);
+ logger.error("Failed to register axis bind \"{}\"", id, e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Failed to register axis bind \"" + id + "\"", e);
+ logger.error("Failed to register axis bind \"{}\"", id, e);
}
} else {
- logger.log(Level.WARNING, "Failed to register axis bind \"" + id + "\", does not extend BindAxisEvent");
+ logger.error("Failed to register axis bind \"{}\", does not extend BindAxisEvent", id);
}
}
}
@@ -246,14 +246,14 @@ private void registerButtonBinds(String packageName, Iterable<Class<?>> classes,
inputSystem.linkBindButtonToInput(input, id);
}
- logger.log(Level.INFO, "Registered button bind: " + id);
+ logger.debug("Registered button bind: {}", id);
} catch (InstantiationException e) {
- logger.log(Level.SEVERE, "Failed to register button bind \"" + id + "\"", e);
+ logger.error("Failed to register button bind \"{}\"", e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Failed to register button bind \"" + id + "\"", e);
+ logger.error("Failed to register button bind \"{}\"", e);
}
} else {
- logger.log(Level.WARNING, "Failed to register button bind \"" + id + "\", does not extend BindButtonEvent");
+ logger.error("Failed to register button bind \"{}\", does not extend BindButtonEvent", id);
}
}
}
@@ -272,10 +272,10 @@ private void loadPrefabs() {
persisterHelper.deserializePrefab(prefabData, prefabURI.getPackage());
}
} else {
- logger.severe("Failed to load prefab '" + prefabURI + "'");
+ logger.warn("Failed to load prefab '{}'", prefabURI);
}
} catch (IOException e) {
- logger.log(Level.WARNING, "Failed to load prefab '" + prefabURI + "'", e);
+ logger.error("Failed to load prefab '{}'", prefabURI, e);
}
}
}
@@ -310,7 +310,7 @@ public void deactivate() {
try {
CoreRegistry.get(WorldPersister.class).save(new File(PathManager.getInstance().getWorldSavePath(CoreRegistry.get(WorldProvider.class).getTitle()), ENTITY_DATA_FILE), WorldPersister.SaveFormat.Binary);
} catch (IOException e) {
- logger.log(Level.SEVERE, "Failed to save entities", e);
+ logger.error("Failed to save entities", e);
}
dispose();
entityManager.clear();
@@ -363,7 +363,7 @@ public void initWorld() {
worldInfo.setSeed(random.randomCharacterString(16));
}
- logger.log(Level.INFO, "World seed: \"{0}\"", worldInfo.getSeed());
+ logger.info("World seed: \"{0}\"", worldInfo.getSeed());
// Init ChunkGeneratorManager
ChunkGeneratorManager chunkGeneratorManager = ChunkGeneratorManagerImpl.buildChunkGenerator(Arrays.asList(worldInfo.getChunkGenerators()));
@@ -391,7 +391,7 @@ public void initWorld() {
try {
CoreRegistry.get(WorldPersister.class).load(entityDataFile, WorldPersister.SaveFormat.Binary);
} catch (IOException e) {
- logger.log(Level.SEVERE, "Failed to load entity data", e);
+ logger.error("Failed to load entity data", e);
}
}
View
2  src/main/java/org/terasology/input/InputSystem.java
@@ -44,7 +44,6 @@
import java.util.List;
import java.util.Map;
-import java.util.logging.Logger;
/**
* This system processes input, sending it out as events against the LocalPlayer entity.
@@ -53,7 +52,6 @@
* to one or more inputs.
*/
public class InputSystem implements EventHandlerSystem {
- private Logger logger = Logger.getLogger(getClass().getName());
private float mouseSensitivity = (float) Config.getInstance().getMouseSens();
View
3  src/main/java/org/terasology/logic/manager/AudioManager.java
@@ -17,7 +17,6 @@
import java.util.HashMap;
import java.util.Map;
-import java.util.logging.Logger;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3d;
@@ -45,8 +44,6 @@
*/
public abstract class AudioManager implements SoundManager {
- protected Logger logger = Logger.getLogger(this.getClass().getCanonicalName());
-
private static AudioManager _instance = null;
protected Map<String, Sound> _audio = new HashMap<String, Sound>();
View
16 src/main/java/org/terasology/logic/manager/CommandManager.java
@@ -30,6 +30,8 @@
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.game.CoreRegistry;
import org.terasology.logic.commands.Command;
import org.terasology.logic.commands.CommandParam;
@@ -48,8 +50,6 @@
import java.util.Comparator;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import static org.reflections.ReflectionUtils.withAnnotation;
import static org.reflections.ReflectionUtils.withModifier;
@@ -60,7 +60,7 @@
* @author Marcel Lehwald <marcel.lehwald@googlemail.com>
*/
public class CommandManager {
- private final Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(CommandManager.class);
private final List<CommandInfo> commands = new ArrayList<CommandInfo>();
private final Table<String, Integer, CommandInfo> commandLookup = HashBasedTable.create();
@@ -140,7 +140,7 @@ public void methodExecute(String params) {
bind.setVariable(bindName, provider);
GroovyShell shell = new GroovyShell(bind);
- logger.log(Level.INFO, bindName + "." + name + "(" + params + ")");
+ logger.debug("Executing command {}.{}({})", bindName, name, params);
shell.evaluate(bindName + "." + name + "(" + params + ")");
}
}
@@ -171,9 +171,9 @@ private void loadCommands() {
commandLookup.put(command.getName(), command.getParameterCount(), command);
}
} catch (InstantiationException e) {
- logger.log(Level.SEVERE, "Failed to instantiate command provider " + providerClass.getName(), e);
+ logger.error("Failed to instantiate command provider {}", providerClass.getName(), e);
} catch (IllegalAccessException e) {
- logger.log(Level.SEVERE, "Failed to instantiate command provider " + providerClass.getName(), e);
+ logger.error("Failed to instantiate command provider {}", providerClass.getName(), e);
}
}
@@ -249,7 +249,7 @@ would suggest returning it as part of the result instead (need less singletons!)
return false;
}
String executeString = paramsStr;
- logger.log(Level.INFO, "Execute command with params '" + paramsStr + "'");
+ logger.debug("Execute command with params '{}'");
try {
//execute the command
@@ -260,7 +260,7 @@ would suggest returning it as part of the result instead (need less singletons!)
//TODO better error handling and error message
MessageManager.getInstance().addMessage(cmd.getUsageMessage());
MessageManager.getInstance().addMessage("Error executing command '" + commandName + "'.");
- logger.log(Level.WARNING, "Failed to run command", e);
+ logger.warn("Failed to execute command", e);
return false;
}
View
14 src/main/java/org/terasology/logic/manager/Config.java
@@ -21,13 +21,13 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.vecmath.Vector2f;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.PixelFormat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.game.CoreRegistry;
import org.terasology.protobuf.Configuration;
import org.terasology.rendering.world.WorldRenderer;
@@ -39,7 +39,7 @@
* @author Kai Kratz <kaikratz@googlemail.com>
*/
public final class Config {
- private Logger logger = Logger.getLogger(getClass().getName());
+ private static final Logger logger = LoggerFactory.getLogger(Config.class);
private final static Config _instance = new Config();
private Configuration.Setting.Builder _setting;
@@ -66,14 +66,14 @@ public boolean loadConfig(File file) {
Configuration.Setting.Builder setting = Configuration.Setting.newBuilder();
if (file.exists()) {
- logger.log(Level.INFO, "Using config file: " + file);
+ logger.debug("Using config file: {}", file);
try {
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis);
TextFormat.merge(isr, setting);
isr.close();
} catch (Exception e) {
- logger.log(Level.WARNING, "Could not load config file " + file, e);
+ logger.error("Could not load config file {}", file, e);
return false;
}
}
@@ -83,13 +83,13 @@ public boolean loadConfig(File file) {
public void saveConfig(File file) {
try {
- logger.log(Level.INFO, "Using config file: " + file);
+ logger.debug("Using config file: {}", file);
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos);
TextFormat.print(_setting.build(), osw);
osw.close();
} catch (Exception e) {
- logger.log(Level.WARNING, "Could not write " + file, e);
+ logger.error("Could not write {}", file, e);
}
}
View
25 src/main/java/org/terasology/logic/manager/FontManager.java
@@ -17,12 +17,12 @@
import java.io.IOException;
import java.util.HashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.newdawn.slick.AngelCodeFont;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.util.ResourceLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Provides global access to fonts.
@@ -31,16 +31,17 @@
*/
public class FontManager {
- private Logger logger = Logger.getLogger(getClass().getName());
- private final HashMap<String, AngelCodeFont> _fonts = new HashMap<String, AngelCodeFont>();
- private static FontManager _instance = null;
+ private static final Logger logger = LoggerFactory.getLogger(FontManager.class);
+
+ private final HashMap<String, AngelCodeFont> fonts = new HashMap<String, AngelCodeFont>();
+ private static FontManager instance = null;
public static FontManager getInstance() {
- if (_instance == null) {
- _instance = new FontManager();
+ if (instance == null) {
+ instance = new FontManager();
}
- return _instance;
+ return instance;
}
private FontManager() {
@@ -49,15 +50,15 @@ private FontManager() {
private void initFonts() {
try {
- _fonts.put("default", new AngelCodeFont("Font", ResourceLoader.getResource("assets/fonts/default.fnt").openStream(), ResourceLoader.getResource("assets/fonts/default_0.png").openStream()));
+