Skip to content

Commit 50f7f21

Browse files
committed
feat(logging): Improve AppMap agent logging and config output
The AppMap agent's logging has been enhanced for better readability and detail. This includes: - Setting a standardized log format for all messages to yyyy-MM-dd HH:mm:ss [thread] AppMap level: message. - Refining the AppMapConfig toString() method to provide a more structured and comprehensive output of the configuration details, including name, config file path, and package information. - Adjusting log levels for system properties output in Agent.java from info to debug, and removing a redundant stack trace in debug mode for cleaner logs.
1 parent 78d2523 commit 50f7f21

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

agent/src/main/java/com/appland/appmap/Agent.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ public static void premain(String agentArgs, Instrumentation inst) {
7272
logger.info("Agent version {}, current time mills: {}",
7373
implementationVersion, start);
7474
logger.info("config: {}", AppMapConfig.get());
75-
logger.info("System properties: {}", System.getProperties());
76-
logger.debug(new Exception(), "whereAmI");
75+
logger.debug("System properties: {}", System.getProperties());
7776

7877
addAgentJars(agentArgs, inst);
7978

agent/src/main/java/com/appland/appmap/config/AppMapConfig.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ public static TaggedLogger configureLogging() {
317317
// tinylog freezes its configuration after the first call to any of its
318318
// methods other than those in Configuration. So, get everything ready
319319
// before returning the logger for this class;
320+
Configuration.set("writer.format", "{date:yyyy-MM-dd HH:mm:ss} [{thread}] AppMap {level}: {message}");
321+
320322
if (Properties.Debug) {
321323
Configuration.set("level", "debug");
322324
}
@@ -365,6 +367,25 @@ private static Path findDefaultOutputDirectory(FileSystem fs) {
365367

366368
@Override
367369
public String toString() {
368-
return JSON.toJSONString(this, true);
370+
StringBuilder sb = new StringBuilder();
371+
sb.append("name: ").append(name).append("\n");
372+
if (configFile != null) {
373+
sb.append("configFile: ").append(configFile).append("\n");
374+
}
375+
sb.append("packages: ");
376+
if (packages == null || packages.length == 0) {
377+
sb.append("[]");
378+
} else {
379+
for (AppMapPackage pkg : packages) {
380+
sb.append("\n - path: ").append(pkg.path);
381+
if (pkg.shallow) {
382+
sb.append("\n shallow: true");
383+
}
384+
if (pkg.exclude != null && pkg.exclude.length > 0) {
385+
sb.append("\n exclude: ").append(Arrays.toString(pkg.exclude));
386+
}
387+
}
388+
}
389+
return sb.toString();
369390
}
370391
}

0 commit comments

Comments
 (0)