Skip to content

Commit

Permalink
Refactored log capture and formatting code in org.openqa.selenium.tes… (
Browse files Browse the repository at this point in the history
#13322)

* Refactored log capture and formatting code in org.openqa.selenium.testing and org.openqa.selenium.grid.log packages.

* Format files

---------

Co-authored-by: Diego Molina <[email protected]>
Co-authored-by: Diego Molina <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2023
1 parent bb10753 commit 273c3d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions java/src/org/openqa/selenium/grid/log/TerseFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class TerseFormatter extends Formatter {
* Line separator string. This is the value of the line.separator property at the moment that the
* TerseFormatter was created.
*/
private final String lineSeparator = System.getProperty("line.separator");
private final String lineSeparator = System.lineSeparator();

/*
* DGF - These have to be compile time constants to be used with switch
Expand Down Expand Up @@ -78,7 +78,12 @@ public synchronized String format(final LogRecord record) {
buffer.append(' ');
buffer.append(levelNumberToCommonsLevelName(record.getLevel()));
String[] parts = record.getSourceClassName().split("\\.");
buffer.append(" [" + parts[parts.length - 1] + "." + record.getSourceMethodName() + "]");
buffer
.append(" [")
.append(parts[parts.length - 1])
.append(".")
.append(record.getSourceMethodName())
.append("]");
buffer.append(SUFFIX);
buffer.append(formatMessage(record)).append(lineSeparator);
if (record.getThrown() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String format(LogRecord record) {
.append("]");
}
buffer.append(" - ");
buffer.append(formatMessage(record)).append(System.getProperty("line.separator"));
buffer.append(formatMessage(record)).append(System.lineSeparator());
if (record.getThrown() != null) {
final StringWriter trace = new StringWriter();
record.getThrown().printStackTrace(new PrintWriter(trace));
Expand Down

0 comments on commit 273c3d4

Please sign in to comment.