Skip to content

Commit 37c3be0

Browse files
committed
Correcting debug method
1 parent 286df45 commit 37c3be0

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/main/java/com/github/jshaptic/minimatch/Minimatch.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,28 +1162,30 @@ private static boolean hasOption(int options, int o) {
11621162

11631163
// PORT_INFO: method for printing debug information
11641164
private void debug(boolean hasLogline, Object... vars) {
1165-
if (hasOption(options, DEBUG)) {
1166-
String logline = "";
1167-
if (hasLogline) {
1168-
Object[] v = {};
1169-
if (vars != null && vars.length > 0 && vars[0] instanceof String) {
1170-
logline = vars[0].toString();
1171-
if (vars.length > 1) {
1172-
v = new Object[vars.length - 2];
1173-
for (int i = 0; i < v.length; i++) {
1174-
v[i] = vars[i + 1];
1175-
}
1165+
if (!hasOption(options, DEBUG)) {
1166+
return;
1167+
}
1168+
1169+
String logline = "";
1170+
if (hasLogline) {
1171+
Object[] v = {};
1172+
if (vars != null && vars.length > 0 && vars[0] instanceof String) {
1173+
logline = vars[0].toString();
1174+
if (vars.length > 1) {
1175+
v = new Object[vars.length - 2];
1176+
for (int i = 0; i < v.length; i++) {
1177+
v[i] = vars[i + 1];
11761178
}
11771179
}
1178-
System.out.format("%s: ", Thread.currentThread().getStackTrace()[2].getLineNumber());
1179-
System.out.format(logline + "\n", v);
1180-
} else if (vars != null) {
1181-
for (int i = 0; i < vars.length; i++) {
1182-
logline += "%s ";
1183-
}
1184-
System.out.format("%s: ", Thread.currentThread().getStackTrace()[2].getLineNumber());
1185-
System.out.format(logline.trim() + "\n", vars);
11861180
}
1181+
System.out.format("%s: ", Thread.currentThread().getStackTrace()[2].getLineNumber());
1182+
System.out.format(logline + "\n", v);
1183+
} else if (vars != null) {
1184+
for (int i = 0; i < vars.length; i++) {
1185+
logline += "%s ";
1186+
}
1187+
System.out.format("%s: ", Thread.currentThread().getStackTrace()[2].getLineNumber());
1188+
System.out.format(logline.trim() + "\n", vars);
11871189
}
11881190
}
11891191

0 commit comments

Comments
 (0)