The `@log` does not use mixed or wrapper, but directly uses macro to generate default log object and operate log.
- Note
-`verbose` Whether to enable detailed log.
-`logType` Specifies the type of `log` that needs to be generated, default is `io.github.dreamylost.LogType.JLog`.
-`io.github.dreamylost.LogType.JLog` use `java.util.logging.Logger`
-`io.github.dreamylost.LogType.Log4j2` use `org.apache.logging.log4j.Logger`
-`io.github.dreamylost.LogType.Slf4j` use `org.slf4j.Logger`
- Support `class`, `case class` and `object`.
> IDE support is not very good, a red prompt will appear, but the compilation is OK. You need to provide their dependencies and configuration, please refer to the test.
The `@apply` used to generate `apply` method for primary construction of ordinary classes.
- Note
-`verbose` Whether to enable detailed log.
- Only support `class`.
- Only support **primary construction**.
- Currying is not supported for constructors at present.
> IDE support is not very good, a red prompt will appear, but the compilation is OK. You need to provide their dependencies and configuration, please refer to the test.
"""@log(verbose=true) class TestClass1(val i: Int = 0, var j: Int) {
log.info("hello")
}"""shouldcompile
"""@log class TestClass2(val i: Int = 0, var j: Int)"""shouldcompile
"""@log() class TestClass3(val i: Int = 0, var j: Int)"""shouldcompile
"""@log(verbose=true) class TestClass4(val i: Int = 0, var j: Int)"""shouldcompile
"""@log(logType=io.github.dreamylost.LogType.Log4j2) class TestClass5(val i: Int = 0, var j: Int)"""shouldcompile
"""@log(verbose=true, logType=io.github.dreamylost.LogType.Log4j2) class TestClass6(val i: Int = 0, var j: Int)"""shouldcompile
}
"log7 slf4j"should"ok on class"in{
"""@log(verbose=true) class TestClass1(val i: Int = 0, var j: Int) {
log.info("hello")
}"""shouldcompile
"""@toString @builder @log class TestClass2(val i: Int = 0, var j: Int)"""shouldcompile//Use with multiple annotations
"""@log() class TestClass3(val i: Int = 0, var j: Int)"""shouldcompile
"""@log(verbose=true) class TestClass4(val i: Int = 0, var j: Int)"""shouldcompile
"""@log(logType=io.github.dreamylost.LogType.Slf4j) class TestClass5(val i: Int = 0, var j: Int)"""shouldcompile
"""@log(verbose=true, logType=io.github.dreamylost.LogType.Slf4j) class TestClass6(val i: Int = 0, var j: Int)"""shouldcompile
"""@log(verbose=true, logType=io.github.dreamylost.LogType.Slf4j) class TestClass6(val i: Int = 0, var j: Int){ log.info("hello world") }"""shouldcompile
"""@log(io.github.dreamylost.LogType.Slf4j) class TestClass6(val i: Int = 0, var j: Int){ log.info("hello world") }"""shouldcompile//default verbose is false