Skip to content

Commit

Permalink
Use logger instead of println
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbata committed Oct 6, 2023
1 parent b5e473e commit 4f1dfc4
Show file tree
Hide file tree
Showing 73 changed files with 708 additions and 527 deletions.
2 changes: 1 addition & 1 deletion src/automap/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ public final void initVariables() {
// find player to center on initially
if (!DOOM.playeringame[pnum = DOOM.consoleplayer]) {
for (pnum = 0; pnum < MAXPLAYERS; pnum++) {
System.out.println(pnum);
//System.out.println(pnum);
if (DOOM.playeringame[pnum]) {
break;
}
Expand Down
6 changes: 4 additions & 2 deletions src/awt/DoomWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import m.Settings;
import mochadoom.Engine;
import mochadoom.Loggers;
Expand All @@ -36,6 +37,7 @@
* That sort of things.
*/
public class DoomWindowController<E extends Component & DoomWindow<E>, H extends Enum<H> & EventBase<H>> implements FullscreenOptions {
private static final Logger LOGGER = Loggers.getLogger(DoomWindow.class.getName());

private static final long ALL_EVENTS_MASK = 0xFFFF_FFFF_FFFF_FFFFL;

Expand Down Expand Up @@ -82,7 +84,7 @@ private void sizeInit() {
updateSize();
}
} catch (Exception e) {
Loggers.getLogger(DoomWindow.class.getName()).log(Level.SEVERE,
LOGGER.log(Level.SEVERE,
String.format("Error creating DOOM AWT frame. Exiting. Reason: %s", e.getMessage()), e);
throw e;
}
Expand All @@ -97,7 +99,7 @@ public EventObserver<H> getObserver() {
}

public boolean switchFullscreen() {
Loggers.getLogger(DoomFrame.class.getName()).log(Level.WARNING, "FULLSCREEN SWITHED");
LOGGER.log(Level.INFO, "FULLSCREEN SWITHED");
// remove the frame from view
doomFrame.dispose();
doomFrame = new DoomFrame<>(dimension, component, doomFrame.imageSupplier);
Expand Down
7 changes: 5 additions & 2 deletions src/defines/DoomVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import doom.DoomMain;
import java.util.logging.Level;
import java.util.logging.Logger;
import mochadoom.Loggers;
import utils.C2JUtils;
import static utils.C2JUtils.testReadAccess;
Expand All @@ -42,6 +43,8 @@ private DoomVersion(String wadFileName) {
this.wadFileName = wadFileName;
}

private static final Logger LOGGER = Loggers.getLogger(DoomVersion.class.getName());

/**
* Try all versions in given doomwaddir
*
Expand All @@ -56,7 +59,7 @@ public static String tryAllWads(final DoomMain<?, ?> DOOM, final String doomwadd
// C'est ridicule!
// Let's handle languages in config files, okay?
DOOM.language = Language_t.french;
System.out.println("French version\n");
//System.out.println("French version\n");
}

return vFullPath;
Expand Down Expand Up @@ -85,7 +88,7 @@ public static GameMode tryOnlyOne(String iwad, String doomwaddir) {
}

} catch (IllegalArgumentException ex) {
Loggers.getLogger(DoomVersion.class.getName()).log(Level.WARNING, iwad, ex);
LOGGER.log(Level.WARNING, iwad, ex);
}

// It's either invalid or we can't read it.
Expand Down
14 changes: 9 additions & 5 deletions src/doom/CVarManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Optional;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import mochadoom.Loggers;
import utils.ResourceIO;

Expand All @@ -38,11 +39,14 @@
* @author Good Sign
*/
public class CVarManager {
private static final Logger LOGGER = Loggers.getLogger(CVarManager.class.getName());


private final EnumMap<CommandVariable, Object[]> cVarMap = new EnumMap<>(CommandVariable.class);

public CVarManager(final List<String> commandList) {
System.out.println(processAllArgs(commandList) + " command-line variables");
LOGGER.log(Level.INFO,
String.format("%d command-line variables", processAllArgs(commandList)));
}

/**
Expand Down Expand Up @@ -156,9 +160,9 @@ public <T> boolean override(final CommandVariable cv, final T value, final int p
private void readResponseFile(final String filename) {
final ResponseReader r = new ResponseReader();
if (new ResourceIO(filename).readLines(r)) {
System.out.println(String.format("Found response file %s, read %d command line variables", filename, r.cVarCount));
LOGGER.log(Level.INFO,String.format("Found response file %s, read %d command line variables", filename, r.cVarCount));
} else {
System.out.println(String.format("No such response file %s!", filename));
LOGGER.log(Level.WARNING,String.format("No such response file %s!", filename));
System.exit(1);
}
}
Expand Down Expand Up @@ -251,7 +255,7 @@ private Object formatArgValue(final Class<?> format, final String arg) {
try {
return Integer.parseInt(arg);
} catch (NumberFormatException ex) {
Loggers.getLogger(CommandVariable.class.getName()).log(Level.WARNING, null, ex);
LOGGER.log(Level.WARNING, "formatArgValue failure", ex);
return null;
}
} else if (format == String.class) {
Expand All @@ -265,7 +269,7 @@ private Object formatArgValue(final Class<?> format, final String arg) {
| IllegalAccessException
| IllegalArgumentException
| InvocationTargetException ex) {
Loggers.getLogger(CommandVariable.class.getName()).log(Level.SEVERE, null, ex);
LOGGER.log(Level.SEVERE, "formatArgValue failure", ex);
return null;
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/doom/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import m.Settings;
import static m.Settings.SETTINGS_MAP;
import mochadoom.Loggers;
import utils.ParseString;
import utils.QuoteType;
import utils.ResourceIO;
Expand All @@ -38,6 +41,8 @@
*/
public class ConfigManager {

private static final Logger LOGGER = Loggers.getLogger(ConfigManager.class.getName());

private static final Pattern SPLITTER = Pattern.compile("[ \t\n\r\f]+");

private final List<Files> configFiles = ConfigBase.getFiles();
Expand Down Expand Up @@ -224,7 +229,7 @@ private void LoadDefaults() {
configMap.put(setting, setting.defaultValue);
});

System.out.print("M_LoadDefaults: Load system defaults.\n");
LOGGER.log(Level.INFO, "M_LoadDefaults: Load system defaults.");
this.configFiles.forEach(file -> {
final Optional<ResourceIO> maybeRIO = file.firstValidPathIO();

Expand All @@ -240,7 +245,7 @@ private void LoadDefaults() {
}

private boolean readFoundConfig(Files file, ResourceIO rio) {
System.out.print(String.format("M_LoadDefaults: Using config %s.\n", rio.getFileame()));
LOGGER.log(Level.INFO, String.format("M_LoadDefaults: Using config %s.", rio.getFileame()));
if (rio.readLines(line -> {
final String[] split = SPLITTER.split(line, 2);
if (split.length < 2) {
Expand All @@ -256,7 +261,7 @@ private boolean readFoundConfig(Files file, ResourceIO rio) {
.orElse(split[1]);

if (update(setting, value) == UpdateStatus.INVALID) {
System.err.printf("WARNING: invalid config value for: %s in %s \n", name, rio.getFileame());
LOGGER.log(Level.WARNING, String.format("WARNING: invalid config value for: %s in %s", name, rio.getFileame()));
} else {
setting.rebase(file);
}
Expand All @@ -267,7 +272,7 @@ private boolean readFoundConfig(Files file, ResourceIO rio) {
}

// Something went bad, but this won't destroy successfully read values, though.
System.err.printf("Can't read the settings file %s\n", rio.getFileame());
LOGGER.log(Level.SEVERE, String.format("Can't read the settings file %s", rio.getFileame()));
return false;
}

Expand Down
Loading

0 comments on commit 4f1dfc4

Please sign in to comment.