Skip to content

Commit

Permalink
#114 polished
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 13, 2022
1 parent c3b5fa1 commit e8f0ed4
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/log/Colors.java
Expand Up @@ -87,7 +87,7 @@ public final String ansi(final String meta) {
*/
private static ConcurrentMap<String, String> colorMap() {
final ConcurrentMap<String, String> map =
new ConcurrentHashMap<>();
new ConcurrentHashMap<>(0);
map.put("black", "30");
map.put("blue", "34");
map.put("cyan", "36");
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/jcabi/log/DomDecor.java
Expand Up @@ -93,13 +93,11 @@ public void formatTo(final Formatter formatter, final int flags,
new DOMSource(this.node),
new StreamResult(writer)
);
} catch (final TransformerConfigurationException ex) {
throw new IllegalStateException(ex);
} catch (final TransformerException ex) {
throw new IllegalStateException(ex);
}
}
formatter.format("%s", writer.toString());
formatter.format("%s", writer);
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/log/ListDecor.java
Expand Up @@ -85,7 +85,7 @@ public void formatTo(final Formatter formatter, final int flags,
}
}
builder.append(']');
formatter.format("%s", builder.toString());
formatter.format("%s", builder);
}

}
4 changes: 1 addition & 3 deletions src/main/java/com/jcabi/log/Logger.java
Expand Up @@ -490,9 +490,7 @@ private static org.slf4j.Logger logger(final Object source) {
final Field fqcn = logger.getClass()
.getDeclaredField("FQCN");
setFinalStatic(fqcn, Logger.class.getName());
} catch (final NoSuchFieldException ex) {
throw new IllegalStateException(ex);
} catch (final IllegalAccessException ex) {
} catch (final NoSuchFieldException | IllegalAccessException ex) {
throw new IllegalStateException(ex);
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/jcabi/log/MulticolorLayout.java
Expand Up @@ -30,7 +30,6 @@
package com.jcabi.log;

import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.log4j.EnhancedPatternLayout;
Expand Down Expand Up @@ -122,7 +121,7 @@ public void setColors(final String cols) {
final Map<String, String> parsed = new ParseableInformation(
cols
).information();
for (final Entry<String, String> entry : parsed.entrySet()) {
for (final Map.Entry<String, String> entry : parsed.entrySet()) {
this.colors.addColor(entry.getKey(), entry.getValue());
}
if (this.base != null) {
Expand All @@ -141,7 +140,7 @@ public void setLevels(final String lev) {
final Map<String, String> parsed = new ParseableLevelInformation(
lev
).information();
for (final Entry<String, String> entry : parsed.entrySet()) {
for (final Map.Entry<String, String> entry : parsed.entrySet()) {
this.levels.put(entry.getKey(), entry.getValue());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/log/ObjectDecor.java
Expand Up @@ -62,7 +62,7 @@ public void formatTo(final Formatter formatter, final int flags,
formatter.format("NULL");
} else if (this.object.getClass().isArray()) {
formatter.format(
new ArrayFormatAction((Object[]) this.object).run()
new ObjectDecor.ArrayFormatAction((Object[]) this.object).run()
);
} else {
final String output =
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/jcabi/log/ParseableLevelInformation.java
Expand Up @@ -32,7 +32,6 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.log4j.Level;

/**
Expand Down Expand Up @@ -65,7 +64,7 @@ public final Map<String, String> information() {
this.content
).information();
final Map<String, String> converted = new HashMap<>(0);
for (final Entry<String, String> entry : parsed.entrySet()) {
for (final Map.Entry<String, String> entry : parsed.entrySet()) {
final String level = entry.getKey().toUpperCase(Locale.ENGLISH);
if (Level.toLevel(level, null) == null) {
throw new IllegalStateException(
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/jcabi/log/ObjectDecorTest.java
Expand Up @@ -77,11 +77,11 @@ private static Collection<Object[]> params() {
new Object[][] {
{null, "NULL", 0, 0, 0},
{new SecretDecor("x"), "{secret: \"x\"}", 0, 0, 0},
{new Foo(1, "one"), "{num: \"1\", name: \"one\"}", 0, 0, 0},
{new ObjectDecorTest.Foo(1, "one"), "{num: \"1\", name: \"one\"}", 0, 0, 0},
// @checkstyle MethodBodyComments (6 lines)
// @checkstyle LineLength (3 lines)
{
new Object[]{new Foo(0, "zero"), new Foo(2, "two")},
new Object[]{new ObjectDecorTest.Foo(0, "zero"), new ObjectDecorTest.Foo(2, "two")},
"[{num: \"0\", name: \"zero\"}, {num: \"2\", name: \"two\"}]",
0, 0, 0,
},
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/com/jcabi/log/VerboseProcessTest.java
Expand Up @@ -307,8 +307,8 @@ public void terminatesMonitorsAndProcessIfClosedNormal() throws Exception {
*/
private void terminatesMonitorsAndProcessIfClosed(final long delay)
throws Exception {
final InputStream input = new InfiniteInputStream('i');
final InputStream error = new InfiniteInputStream('e');
final InputStream input = new VerboseProcessTest.InfiniteInputStream('i');
final InputStream error = new VerboseProcessTest.InfiniteInputStream('e');
final Process prc = Mockito.mock(Process.class);
Mockito.doReturn(input).when(prc).getInputStream();
Mockito.doReturn(error).when(prc).getErrorStream();
Expand All @@ -335,7 +335,7 @@ private void terminatesMonitorsAndProcessIfClosed(final long delay)
new SimpleLayout(),
writer
);
appender.addFilter(new VrbPrcMonitorFilter(process));
appender.addFilter(new VerboseProcessTest.VrbPrcMonitorFilter(process));
org.apache.log4j.Logger.getLogger(
VerboseProcess.class
).addAppender(appender);
Expand Down Expand Up @@ -411,7 +411,7 @@ public int read() throws IOException {
final int next;
if (this.feed) {
this.feed = false;
next = InfiniteInputStream.LINE_FEED;
next = VerboseProcessTest.InfiniteInputStream.LINE_FEED;
} else {
this.feed = true;
next = this.chr;
Expand Down Expand Up @@ -459,7 +459,7 @@ private final class VrbPrcMonitorFilter extends Filter {
public int decide(final LoggingEvent event) {
final String thread = event.getThreadName();
final int decision;
if (thread.startsWith(VrbPrcMonitorFilter.THREADNAME_START
if (thread.startsWith(VerboseProcessTest.VrbPrcMonitorFilter.THREADNAME_START
+ this.hash
)) {
decision = Filter.ACCEPT;
Expand Down

0 comments on commit e8f0ed4

Please sign in to comment.