// Note that it will not judge whether synchronized already exists, so if synchronized already exists, it will be used twice.
...
...
@@ -178,10 +184,7 @@ The `@log` does not use mixed or wrapper, but directly uses macro to generate de
-`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.
- Support `class`, `case class` and `object`.
- Example
...
...
@@ -201,9 +204,6 @@ The `@apply` used to generate `apply` method for primary construction of ordinar
-`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.
- Example
...
...
@@ -212,6 +212,39 @@ The `@apply` used to generate `apply` method for primary construction of ordinar
println(B2(1,2))
```
## @constructor
The `@constructor` used to generate secondary constructor method for classes.
- Note
-`verbose` Whether to enable detailed log.
-`excludeFields` Whether to exclude the specified `var` fields, default is `Nil`.
@@ -13,8 +13,8 @@ class LogTest extends AnyFlatSpec with Matchers {
"log1"should"ok on class"in{
"""@log(verbose=true) class TestClass1(val i: Int = 0, var j: Int) {
log.info("hello")
}"""shouldcompile
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
...
...
@@ -25,8 +25,8 @@ class LogTest extends AnyFlatSpec with Matchers {
"log2"should"ok on case class"in{
"""@log(verbose=true) case class TestClass1(val i: Int = 0, var j: Int) {
log.info("hello")
}"""shouldcompile
log.info("hello")
}"""shouldcompile
"""@log case class TestClass2(val i: Int = 0, var j: Int)"""shouldcompile
"""@log() case class TestClass3(val i: Int = 0, var j: Int)"""shouldcompile
...
...
@@ -37,8 +37,8 @@ class LogTest extends AnyFlatSpec with Matchers {
"log3"should"ok on object"in{
"""@log(verbose=true) object TestClass1 {
log.info("hello")
}"""shouldcompile
log.info("hello")
}"""shouldcompile
"""@log object TestClass2"""shouldcompile
"""@log() object TestClass3"""shouldcompile
...
...
@@ -49,8 +49,8 @@ class LogTest extends AnyFlatSpec with Matchers {
"log4 log4j2"should"ok on object"in{
"""@log(verbose=true) object TestClass1 {
log.info("hello")
}"""shouldcompile
log.info("hello")
}"""shouldcompile
"""@log object TestClass2"""shouldcompile
"""@log() object TestClass3"""shouldcompile
...
...
@@ -61,8 +61,8 @@ class LogTest extends AnyFlatSpec with Matchers {
"log5 slf4j"should"ok on object"in{
"""@log(verbose=true) object TestClass1 {
log.info("hello")
}"""shouldcompile
log.info("hello")
}"""shouldcompile
"""@log object TestClass2"""shouldcompile
"""@log() object TestClass3"""shouldcompile
...
...
@@ -73,8 +73,8 @@ class LogTest extends AnyFlatSpec with Matchers {
"log6 log4j2"should"ok on class"in{
"""@log(verbose=true) class TestClass1(val i: Int = 0, var j: Int) {
log.info("hello")
}"""shouldcompile
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
...
...
@@ -85,8 +85,8 @@ class LogTest extends AnyFlatSpec with Matchers {
"log7 slf4j"should"ok on class"in{
"""@log(verbose=true) class TestClass1(val i: Int = 0, var j: Int) {
log.info("hello")
}"""shouldcompile
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
...
...
@@ -96,4 +96,62 @@ class LogTest extends AnyFlatSpec with Matchers {
"""@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
}
"log8 slf4j"should"ok on class and has object"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) @builder class TestClass6(val i: Int = 0, var j: Int){ log.info("hello world") }