Skip to content

Commit

Permalink
- Rendering kv primitive arguments in message body.
Browse files Browse the repository at this point in the history
- Patch version bump.
  • Loading branch information
jjzazuet committed Oct 27, 2024
1 parent 34ace10 commit f815af8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins { id("io.vacco.oss.gitflow") version "1.0.1" }

group = "io.vacco.shax"
version = "2.0.16.0.4.0"
version = "2.0.16.0.4.1"

configure<io.vacco.oss.gitflow.GsPluginProfileExtension> {
addJ8Spec()
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/io/vacco/shax/logging/ShArgument.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.vacco.shax.logging;

import java.util.Objects;
import static io.vacco.shax.json.ShReflect.*;

public class ShArgument {

Expand All @@ -15,9 +16,15 @@ public static ShArgument kv(String key, Object value) {
}

@Override public String toString() {
return String.format("{%s=%s}",
key, value != null ? value.getClass().getCanonicalName() : "null"
);
String v = "null";
if (value != null) {
if (isBaseType(value) && !isCollection(value)) {
v = value.toString();
} else {
v = value.getClass().getCanonicalName();
}
}
return String.format("{%s=%s}", key, v);
}

}
2 changes: 1 addition & 1 deletion src/test/java/io/vacco/shax/test/ShLoggerSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class ShLoggerSpec {
e("Chi", "Youhei")
);

log.info("Cats and Owners [{}]", kv("catOwners", catOwners));
log.info("Cats and Owners {}", kv("catOwners", catOwners));
log.info("Boolean log {}", kv("boolVal", true));
log.info("Integer log {}", kv("intVal", 42));
log.info("Long log {}", kv("longVal", 42L));
Expand Down

0 comments on commit f815af8

Please sign in to comment.