Skip to content

Commit

Permalink
feedback fluent-logger pr. except to make log line shorter.
Browse files Browse the repository at this point in the history
Co-authored-by: jdrueckert <[email protected]>
  • Loading branch information
soloturn and jdrueckert committed Feb 15, 2024
1 parent 31e6044 commit d203bc6
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void notifyEndListeners(boolean interrupted) {
try {
entry.getValue().onAudioEnd(interrupted);
} catch (Exception e) {
logger.atError().addArgument(() -> entry.getValue()).addArgument(e).log("onAudioEnd() notification failed for {}");
logger.error("onAudioEnd() notification failed for {}", entry.getValue(), e); //NOPMD
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected void doReload(StaticSoundData newData) {
length = (float) size / channels / (bits / 8) / frequency;
});
} catch (InterruptedException e) {
logger.atError().addArgument(() -> getUrn()).addArgument(e).log("Failed to reload {}");
logger.error("Failed to reload {}", getUrn(), e); //NOPMD
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected void doReload(StreamingSoundData data) {
try {
GameThread.synch(this::initializeBuffers);
} catch (InterruptedException e) {
logger.atError().addArgument(() -> getUrn()).addArgument(e).log("Failed to reload {}");
logger.error("Failed to reload {}", getUrn(), e); //NOPMD
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private <T extends AutoConfig> void loadSettingsFromDisk(Class<T> configClass, T
T loadedConfig = (T) serializer.deserialize(TypeInfo.of(configClass), inputStream).get();
mergeConfig(configClass, loadedConfig, config);
} catch (Exception e) {
logger.atError().addArgument(() -> config.getId()).addArgument(e).log("Error while loading config {} from disk");
logger.error("Error while loading config {} from disk", config.getId(), e); //NOPMD
}
}

Expand Down Expand Up @@ -116,7 +116,7 @@ private void saveConfigToDisk(AutoConfig config) {
StandardOpenOption.CREATE)) {
serializer.serialize(config, TypeInfo.of((Class<AutoConfig>) config.getClass()), output);
} catch (IOException e) {
logger.atError().addArgument(() -> config.getId()).addArgument(e).log("Error while saving config {} to disk");
logger.error("Error while saving config {} to disk", config.getId(), e); //NOPMD
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public void initialize() {
}

double seconds = 0.001 * totalInitTime.elapsed(TimeUnit.MILLISECONDS);
logger.atInfo().addArgument(() -> String.format("%.2f", seconds)).log("Initialization completed in {}sec.");
logger.info("Initialization completed in {}sec.", String.format("%.2f", seconds)); //NOPMD
}

private void verifyInitialisation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ModuleInstaller implements Callable<List<Module>> {
@Override
public List<Module> call() throws Exception {
Map<URI, Path> filesToDownload = getDownloadUrls(moduleList);
logger.atInfo().addArgument(() -> filesToDownload.size()).log("Started downloading {} modules");
logger.info("Started downloading {} modules", filesToDownload.size()); //NOPMD
MultiFileDownloader downloader = new MultiFileDownloader(filesToDownload, downloadProgressListener);
List<Path> downloadedModulesPaths = downloader.call();
logger.info("Module download completed, loading the new modules...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void preInitialise(Context rootContext) {
checkServerIdentity();

// TODO: Move to display subsystem
logger.atInfo().addArgument(() -> config.renderConfigAsJson(config.getRendering())).log("Video Settings: {}");
logger.info("Video Settings: {}", config.renderConfigAsJson(config.getRendering())); //NOPMD

rootContext.put(Config.class, config);
//add facades
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public EventMetadata(Class<T> simpleClass, CopyStrategyLibrary copyStrategies, R
skipInstigator = simpleClass.getAnnotation(BroadcastEvent.class).skipInstigator();
}
if (networkEventType != NetworkEventType.NONE && !isConstructable() && !Modifier.isAbstract(simpleClass.getModifiers())) {
logger.atError().addArgument(() -> this).
log("Event '{}' is a network event but lacks a default constructor - will not be replicated");
logger.error("Event '{}' is a network event but lacks a default constructor - will not be replicated", this); //NOPMD
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onFootstep(FootstepEvent event, EntityRef entity, LocationComponent
Block block = worldProvider.getBlock(blockPos);
if (block != null) {
if (block.getSounds() == null) {
logger.atError().addArgument(() -> block.getURI()).log("Block '{}' has no sounds");
logger.error("Block '{}' has no sounds", block.getURI()); //NOPMD
} else if (!block.getSounds().getStepSounds().isEmpty()) {
footstepSounds = block.getSounds().getStepSounds();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ public void initialize() {

for (Class<?> type : environment.getTypesAnnotatedWith(RegisterParticleSystemFunction.class)) {
if (!ParticleSystemFunction.class.isAssignableFrom(type)) {
logger.atError().addArgument(() -> type.getSimpleName()).
log("Cannot register particle system function {}, must be a subclass of ParticleSystemFunction");
logger.error("Cannot register particle system function {}, must be a subclass of ParticleSystemFunction", type.getSimpleName()); //NOPMD
} else {
try {
ParticleSystemFunction function = (ParticleSystemFunction) type.newInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public Class<? extends Event> getEventClass(EntityData.Event eventData) {
}
}
if (metadata == null) {
logger.atWarn().addArgument(() -> eventData.getType()).log("Unable to deserialize unknown event with id: {}");
logger.warn("Unable to deserialize unknown event with id: {}", eventData.getType()); //NOPMD
return null;
}
return metadata.getType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ private void applyComponentChanges(Module context, EntityData.Prefab prefabData,
}
}
} else if (componentData.hasType()) {
logger.atWarn().addArgument(() -> prefabData.getName()).addArgument(() -> componentData.getType()).
log("Prefab '{}' contains unknown component '{}'");
logger.warn("Prefab '{}' contains unknown component '{}'", prefabData.getName(), componentData.getType()); //NOPMD
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ public HitResult rayTrace(Vector3f from, Vector3f direction, float distance, Col
hitNormalWorld,
voxelPosition);
} else { //we hit something we don't understand, assume its nothing and log a warning
logger.atWarn().addArgument(() -> collisionObject.userData).
log("Unidentified object was hit in the physics engine: {}");
logger.warn("Unidentified object was hit in the physics engine: {}", collisionObject.userData); //NOPMD
}
}

Expand Down Expand Up @@ -306,8 +305,7 @@ public HitResult rayTrace(Vector3f from, Vector3f direction, float distance, Set
hitNormalWorld,
voxelPosition);
} else { //we hit something we don't understand, assume its nothing and log a warning
logger.atWarn().addArgument(() -> collisionObject.userData).
log("Unidentified object was hit in the physics engine: {}");
logger.warn("Unidentified object was hit in the physics engine: {}", collisionObject.userData); //NOPMD
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ public void initialise(List<String> registeredBlockFamilies,
if (id != null) {
block.setId(id);
} else {
logger.atError().addArgument(() -> block.getURI()).addArgument(() -> family.get().getURI()).
log("Missing id for block {} in provided family {}");
logger.error("Missing id for block {} in provided family {}", block.getURI(), family.get().getURI()); //NOPMD
if (generateNewIds) {
block.setId(getNextId());
} else {
Expand Down Expand Up @@ -157,8 +156,7 @@ public void receiveFamilyRegistration(BlockUri familyUri, Map<String, Integer> r
if (id != null) {
block.setId((short) id.intValue());
} else {
logger.atError().addArgument(() -> block.getURI()).addArgument(() -> familyUri).
log("Missing id for block {} in registered family {}");
logger.error("Missing id for block {} in registered family {}", block.getURI(), familyUri); //NOPMD
block.setId(UNKNOWN_ID);
}
}
Expand Down Expand Up @@ -191,7 +189,7 @@ protected void registerFamily(BlockFamily family) {

private void registerBlock(Block block, RegisteredState newState) {
if (block.getId() != UNKNOWN_ID) {
logger.atInfo().addArgument(() -> block).addArgument(() -> block.getId()).log("Registered Block {} with id {}");
logger.info("Registered Block {} with id {}", block, block.getId()); //NOPMD
newState.blocksById.put(block.getId(), block);
newState.idByUri.put(block.getURI(), block.getId());
} else {
Expand Down

0 comments on commit d203bc6

Please sign in to comment.