Skip to content

Commit

Permalink
fixup logger initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
heuermh committed Jun 13, 2024
1 parent 69cd801 commit d1fe980
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/github/heuermh/cooper/Cooper.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public final class Cooper {
*/
public static void main(final String[] args) {

// cheat to set system property before initializing logger
if (Arrays.asList(args).contains("--verbose")) {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
}

// install a signal handler to exit on SIGPIPE
sun.misc.Signal.handle(new sun.misc.Signal("PIPE"), new sun.misc.SignalHandler() {
@Override
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/github/heuermh/cooper/Ls.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public final class Ls implements Callable<Integer> {
private List<String> uris;

/** Logger. */
static Logger logger;
private Logger logger = LoggerFactory.getLogger(Ls.class);

/** Human readable formatter. */
static final HumanReadableFormatter FORMATTER = new HumanReadableFormatter();
Expand Down Expand Up @@ -151,7 +151,14 @@ public static void main(final String[] args) {
if (Arrays.asList(args).contains("--verbose")) {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
}
logger = LoggerFactory.getLogger(Cooper.class);

// install a signal handler to exit on SIGPIPE
sun.misc.Signal.handle(new sun.misc.Signal("PIPE"), new sun.misc.SignalHandler() {
@Override
public void handle(final sun.misc.Signal signal) {
System.exit(0);
}
});

System.exit(new CommandLine(new Ls()).execute(args));
}
Expand Down

0 comments on commit d1fe980

Please sign in to comment.