GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DefaultLogger improvements · MomoProgrammer13/pyroscope-java@acff528

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • agent/src/main/java/io/pyroscope/javaagent/impl
    • DefaultLogger.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎agent/src/main/java/io/pyroscope/javaagent/impl/DefaultLogger.java‎

Copy file name to clipboardExpand all lines: agent/src/main/java/io/pyroscope/javaagent/impl/DefaultLogger.java
+18-17Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@
77
import java.text.SimpleDateFormat;
88

99
public class DefaultLogger implements Logger {
10-
public static Logger PRECONFIG_LOGGER = new DefaultLogger(Level.DEBUG, System.err);
11-
static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
12-
final Level l;
13-
final PrintStream out;
10+
public static final Logger PRECONFIG_LOGGER = new DefaultLogger(Level.DEBUG, System.err);
11+
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
12+
private final Level logLevel;
13+
private final PrintStream out;
1414

15-
public DefaultLogger(Level l, PrintStream out) {
16-
this.l = l;
15+
public DefaultLogger(Level logLevel, PrintStream out) {
16+
this.logLevel = logLevel;
1717
this.out = out;
1818
}
1919

2020
@Override
21-
public void log(Level l, String msg, Object... args) {
22-
if (l.level < this.l.level) {
23-
return;
24-
}
25-
String date;
26-
synchronized (this) {
27-
date = DATE_FORMAT.format(System.currentTimeMillis());
28-
}
29-
String msg2 = String.format(msg, args);
21+
public void log(Level logLevel, String msg, Object... args) {
22+
if (logLevel.level < this.logLevel.level) {
23+
return;
24+
}
25+
String date;
26+
synchronized (this) {
27+
date = DATE_FORMAT.format(System.currentTimeMillis());
28+
}
29+
String formattedMsg = (msg == null) ? "null"
30+
: (args == null || args.length == 0) ? msg : String.format(msg, args);
3031

31-
out.printf("%s [%s] %s\n", date, l, msg2);
32-
}
32+
out.printf("%s [%s] %s%n", date, logLevel, formattedMsg);
33+
}
3334

3435
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.