mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
[uast-inspections] IDEA-354390 Support structured logging for SLF4J
- don't highlight if last arguments are structured arguments GitOrigin-RevId: fb0bf20ff547df4e41c5c6a50e89afe29d149f48
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b5ebbd1b62
commit
71cab9b683
@@ -613,5 +613,47 @@ class JavaLoggingPlaceholderCountMatchesArgumentCountInspectionTest : LoggingPla
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
|
||||
fun `test slf4j structured logging`() {
|
||||
inspection.slf4jToLog4J2Type = LoggingPlaceholderCountMatchesArgumentCountInspection.Slf4jToLog4J2Type.NO
|
||||
myFixture.testHighlighting(JvmLanguage.JAVA, """
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static net.logstash.logback.argument.StructuredArguments.kv;
|
||||
class Demo {
|
||||
public static final Logger log = LoggerFactory.getLogger(Demo.class);
|
||||
public void demo() {
|
||||
log.info(<warning descr="More arguments provided (4) than placeholders specified (2)">"Message1 {} {}"</warning>, 1, //should
|
||||
kv("k1", "v1"), 2,
|
||||
kv("k2", "v2")
|
||||
);
|
||||
log.info("Message2 {} {}", 1, 2,
|
||||
kv("k1", "v1"),
|
||||
kv("k2", "v2")
|
||||
);
|
||||
log.info("Message3 {} {}", 1, 2,
|
||||
kv("k1", "v1"),
|
||||
kv("k2", "v2"), new RuntimeException());
|
||||
log.info(<warning descr="More arguments provided (5) than placeholders specified (2)">"Message4 {} {}"</warning>, 1, 2, //should
|
||||
kv("k1", "v1"),
|
||||
kv("k2", "v2"), 3, new RuntimeException());
|
||||
log.info("Message5 {} {}",
|
||||
kv("k1", "v1"),
|
||||
kv("k2", "v2")
|
||||
);
|
||||
log.atInfo().log("Message6 {} {}", 1,
|
||||
kv("k1", "v1"),
|
||||
kv("k2", "v2"));
|
||||
log.atInfo().log(<warning descr="More arguments provided (4) than placeholders specified (2)">"Message7 {} {}"</warning>, 1, //should
|
||||
kv("k1", "v1"),
|
||||
kv("k2", "v2"), 2);
|
||||
|
||||
log.atInfo().log(<warning descr="More arguments provided (5) than placeholders specified (2)">"Message8 {} {}"</warning>, 1, 2, 3, //should
|
||||
kv("k1", "v1"),
|
||||
kv("k2", "v2"));
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user