Skip to content

Commit 942ceb6

Browse files
committed
docs(README.md): Complete the README documentation
1 parent 3c9ad29 commit 942ceb6

5 files changed

Lines changed: 247 additions & 1 deletion

File tree

README.md

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,113 @@
1-
# cloudopt-logger
1+
![Cloudopt Next](https://github.com/cloudoptlab/cloudopt-next/raw/master/logo.png)
2+
3+
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Apache Licenses Badge](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) [![Twitter Badge](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&logo=twitter)](https://twitter.com/CloudoptLab)
4+
5+
6+
Cloudopt-logger is an extensible and configurable logging framework extension based on Kotlin, supporting Java, Kotlin and Android.
7+
8+
![screenshot](https://github.com/cloudoptlab/cloudopt-logger/raw/master/screenshots/01.jpg)
9+
![screenshot](https://github.com/cloudoptlab/cloudopt-logger/raw/master/screenshots/02.jpg)
10+
11+
Features:
12+
13+
14+
- supports color log output.
15+
16+
- support multiple logging frameworks, such as Slf4j, Log4j, and so on.
17+
18+
- easy to extend.
19+
20+
- more user-friendly and convenient to debug output.
21+
22+
[中文文档](https://github.com/cloudoptlab/cloudopt-logger/blob/master/README_ZH.md)
23+
24+
# Installation
25+
26+
Introduce in Maven:
27+
28+
````xml
29+
<dependency>
30+
<groupId>net.cloudopt.logger</groupId>
31+
<artifactId>cloudopt-logger</artifactId>
32+
<version>1.0.0</version>
33+
</dependency>
34+
````
35+
If you are using Slf4j, you need to introduce the appropriate libraries, such as:
36+
37+
````xml
38+
<dependency>
39+
<groupId>org.slf4j</groupId>
40+
<artifactId>slf4j-api</artifactId>
41+
<version>1.7.25</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>ch.qos.logback</groupId>
45+
<artifactId>logback-classic</artifactId>
46+
<version>1.2.3</version>
47+
</dependency>
48+
````
49+
50+
## How to use
51+
52+
Simple to use, just introduce the Logger class. Here are a few examples:
53+
54+
````kotlin
55+
package net.cloudopt.logger
56+
57+
import org.junit.Test
58+
59+
class TestCase {
60+
61+
private val logger = Logger.getLogger(TestCase::class.java)
62+
63+
@Test
64+
fun example1() {
65+
logger.debug("Start init....")
66+
logger.info("Operation successful!")
67+
logger.warn("The value must be not nul.")
68+
logger.error("Unable to acquire lock!")
69+
}
70+
71+
@Test
72+
fun example2() {
73+
logger.info("Please Wait.... ${Colorer.blue("100")}")
74+
logger.info("Please Wait.... ${Colorer.yellow("200")}")
75+
logger.info("Please Wait.... ${Colorer.red("300")}")
76+
}
77+
78+
@Test
79+
fun example3() {
80+
val configuration = LoggerConfiguration()
81+
configuration.run {
82+
this.color = false
83+
}
84+
Logger.configuration = configuration
85+
example1()
86+
}
87+
88+
@Test
89+
fun example4() {
90+
val configuration = LoggerConfiguration()
91+
configuration.run {
92+
this.debugPrefix = "DEBUG"
93+
this.infoPrefix = "INFO"
94+
this.warnPrefix = "WARN"
95+
this.errorPrefix = "ERROR"
96+
}
97+
Logger.configuration = configuration
98+
example1()
99+
}
100+
}
101+
````
102+
103+
If you want to change the color of any output character, just wrap it in a Colorer. Eight colors are already built in.
104+
105+
## How to extend
106+
107+
Support for Slf4j is now built in, and with Slf4j you can support logback, log4j, log4j2, etc. If you need to support it directly or support other logging frameworks, you can do so by referring to Slf4jLoggerProvider.
108+
109+
## Follow us
110+
111+
You can focus on our [twitter](https://twitter.com/CloudoptLab) or is to focus on the micro letter, public the latest news we will via twitter or released to the public.
112+
113+
![](https://github.com/cloudoptlab/cloudopt-logger/raw/master/screenshots/qrcode.jpg)

README_ZH.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
![Cloudopt Next](https://github.com/cloudoptlab/cloudopt-next/raw/master/logo.png)
2+
3+
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Apache Licenses Badge](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) [![Twitter Badge](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&logo=twitter)](https://twitter.com/CloudoptLab)
4+
5+
6+
cloudopt-logger是一个基于Kotlin开发的可扩展、可配置的日志框架扩展,支持Java、Kotlin及Android。
7+
8+
![screenshot](https://github.com/cloudoptlab/cloudopt-logger/raw/master/screenshots/01.jpg)
9+
![screenshot](https://github.com/cloudoptlab/cloudopt-logger/raw/master/screenshots/02.jpg)
10+
11+
具有以下特性:
12+
13+
- 支持彩色的日志输出。
14+
- 支持多种日志框架,如Slf4j、Log4j等等。
15+
- 易于扩展。
16+
- 更人性化和方便调试的输出。
17+
18+
[中文文档](https://github.com/cloudoptlab/cloudopt-logger/blob/master/README_ZH.md)
19+
20+
# 安装
21+
22+
在Maven中引入:
23+
24+
````xml
25+
<dependency>
26+
<groupId>net.cloudopt.logger</groupId>
27+
<artifactId>cloudopt-logger</artifactId>
28+
<version>1.0.0</version>
29+
</dependency>
30+
````
31+
32+
如果您是使用Slf4j的话,需要引入相应的库,如:
33+
34+
````xml
35+
<dependency>
36+
<groupId>org.slf4j</groupId>
37+
<artifactId>slf4j-api</artifactId>
38+
<version>1.7.25</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>ch.qos.logback</groupId>
42+
<artifactId>logback-classic</artifactId>
43+
<version>1.2.3</version>
44+
</dependency>
45+
````
46+
47+
## 如何使用
48+
49+
使用起来非常简单,只需要引入Logger类即可,下面是几个示例:
50+
51+
````kotlin
52+
package net.cloudopt.logger
53+
54+
import org.junit.Test
55+
56+
class TestCase {
57+
58+
private val logger = Logger.getLogger(TestCase::class.java)
59+
60+
@Test
61+
fun example1() {
62+
logger.debug("Start init....")
63+
logger.info("Operation successful!")
64+
logger.warn("The value must be not nul.")
65+
logger.error("Unable to acquire lock!")
66+
}
67+
68+
@Test
69+
fun example2() {
70+
logger.info("Please Wait.... ${Colorer.blue("100")}")
71+
logger.info("Please Wait.... ${Colorer.yellow("200")}")
72+
logger.info("Please Wait.... ${Colorer.red("300")}")
73+
}
74+
75+
@Test
76+
fun example3() {
77+
val configuration = LoggerConfiguration()
78+
configuration.run {
79+
this.color = false
80+
}
81+
Logger.configuration = configuration
82+
example1()
83+
}
84+
85+
@Test
86+
fun example4() {
87+
val configuration = LoggerConfiguration()
88+
configuration.run {
89+
this.debugPrefix = "DEBUG"
90+
this.infoPrefix = "INFO"
91+
this.warnPrefix = "WARN"
92+
this.errorPrefix = "ERROR"
93+
}
94+
Logger.configuration = configuration
95+
example1()
96+
}
97+
}
98+
````
99+
100+
如果您想要修改任何输出的字符的颜色,只需要通过Colorer.xxx的方法包裹即可。目前已经内置了八种颜色。
101+
102+
## 如何扩展
103+
104+
目前已经内置了对Slf4j的支持,通过Slf4j可以支持logback、log4j、log4j2等等,如果您需要直接支持或者支持其他日志框架,您可以参考Slf4jLoggerProvider,自行实现。
105+
106+
## 关注我们
107+
108+
您可以关注我们的[推特](https://twitter.com/CloudoptLab)或者是关注我们的微信公众号,最新消息我们会通过推特或者公众号发布。
109+
110+
![](https://github.com/cloudoptlab/cloudopt-logger/raw/master/screenshots/qrcode.jpg)

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<groupId>org.slf4j</groupId>
8585
<artifactId>slf4j-api</artifactId>
8686
<version>1.7.25</version>
87+
<scope>provided</scope>
8788
</dependency>
8889
<dependency>
8990
<groupId>ch.qos.logback</groupId>

screenshots/qrcode.jpg

27.3 KB
Loading

src/test/kotlin/net/cloudopt/logger/TestCase.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,27 @@ class TestCase {
4040
logger.info("Please Wait.... ${Colorer.yellow("200")}")
4141
logger.info("Please Wait.... ${Colorer.red("300")}")
4242
}
43+
44+
@Test
45+
fun example3() {
46+
val configuration = LoggerConfiguration()
47+
configuration.run {
48+
this.color = false
49+
}
50+
Logger.configuration = configuration
51+
example1()
52+
}
53+
54+
@Test
55+
fun example4() {
56+
val configuration = LoggerConfiguration()
57+
configuration.run {
58+
this.debugPrefix = "DEBUG"
59+
this.infoPrefix = "INFO"
60+
this.warnPrefix = "WARN"
61+
this.errorPrefix = "ERROR"
62+
}
63+
Logger.configuration = configuration
64+
example1()
65+
}
4366
}

0 commit comments

Comments
 (0)