Skip to content

Commit

Permalink
v0.1.2 版本支持配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
FishGoddess committed Mar 30, 2020
2 parents 39931b3 + 4957122 commit 7387004
Show file tree
Hide file tree
Showing 19 changed files with 600 additions and 114 deletions.
11 changes: 9 additions & 2 deletions FUTURE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
## ✒ 未来版本的新特性 (Features in future version)

### v0.1.3
### v0.1.4
* 完善 DurationRollingFile 结构,加入文件个数限制
* 完善 SizeRollingFile 结构,加入文件个数限制

### v0.1.3
* 继续完善配置文件,主要针对内置的日志处理器做适配
* DefaultHandler 和 wrapper 进行配置文件的适配
* JsonHandler 和 wrapper 进行配置文件的适配

### v0.1.2
* 加入配置文件的支持
* 加入配置文件的支持,以近似 Json 格式的配置文件来增加日志记录的灵活性
* 修复 Logger 中 DebugFunc,InfoFunc,WarnFunc,ErrorFunc 等几个方法的文件信息错误问题
* 修复 logit 中 DebugFunc,InfoFunc,WarnFunc,ErrorFunc 等几个方法的文件信息错误问题

### v0.1.1-alpha
* 再次对 Handler 进行重构,尽量优化 Logger 的设计
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## ✒ 历史版本的特性介绍 (Features in old version)

### v0.1.2
> 此版本发布于 2020-03-30
* 加入配置文件的支持,以近似 Json 格式的配置文件来增加日志记录的灵活性
* 修复 Logger 中 DebugFunc,InfoFunc,WarnFunc,ErrorFunc 等几个方法的文件信息错误问题
* 修复 logit 中 DebugFunc,InfoFunc,WarnFunc,ErrorFunc 等几个方法的文件信息错误问题

### v0.1.1-alpha
> 此版本发布于 2020-03-29
* 再次对 Handler 进行重构,尽量优化 Logger 的设计
Expand Down
21 changes: 10 additions & 11 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

[![License](./license.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)

**logit** is an easy-to-use and level-based logger for [GoLang](https://golang.org) applications.
**logit** is an easy-to-use, also level-based and config file first logger for [GoLang](https://golang.org) applications.

[阅读中文版的 Read me](./README.md).

### 🥇 Features

* Modularization design, easy to extend your logger with wrapper and handler
* Level-based logging, and there are four levels to use
* Config file supports, you can use a config file to change you logger flexibility even it has been a binary
* Log Function supports, it is a better way to output a very long log
* Enable or disable Logger, you can disable or switch to a higher level in your production environment
* Log file supports, and you can customer the name of your log file
Expand All @@ -20,9 +21,7 @@
* Time format supports, you can format time in your way
* Log as Json string supports, by using provided JsonLoggerHandler

_Check [HISTORY.md](./HISTORY.md) and [FUTURE.md](./FUTURE.md) to get more information._

> We will redesign some part of logit for more concise and convenient, check branch v0.1.x to learn more information.
_Check [HISTORY.md](./HISTORY.md) and [FUTURE.md](./FUTURE.md) to know about more information._

### 🚀 Installation

Expand All @@ -42,7 +41,7 @@ module your_project_name
go 1.14

require (
github.com/FishGoddess/logit v0.1.1-alpha
github.com/FishGoddess/logit v0.1.2
)
```

Expand Down Expand Up @@ -95,6 +94,7 @@ func main() {
* [basic](./_examples/basic.go)
* [logger](./_examples/logger.go)
* [level_and_disable](./_examples/level_and_disable.go)
* [config_file](./_examples/config_file.go)
* [handler](./_examples/handler.go)
* [wrapper](./_examples/wrapper.go)
* [log_to_file](./_examples/log_to_file.go)
Expand All @@ -104,18 +104,17 @@ _Check more examples in [_examples](./_examples)._
### 🔥 Benchmarks

```bash
$ go test -v ./_examples/benchmarks_test.go -bench=. -benchtime=1s
$ go test -v ./_examples/benchmarks_test.go -bench=. -benchtime=10s
```

> Benchmark file:[_examples/benchmarks_test.go](./_examples/benchmarks_test.go)
| test case | times ran (large is better) | ns/op (small is better) | features | extension |
| -----------|--------|-------------|-------------|-------------|
| **logit** |   **667340** | **1844 ns/op** | powerful | high |
| zap |   401043 | 2793 ns/op | normal | normal |
| logrus |   158262 | 7751 ns/op | normal | normal |
| golog |   751064 | 1614 ns/op | normal | normal |
| golang log | 1269531 |   938 ns/op | not good | none |
| **logit** | **6429907** | **1855 ns/op** | powerful | high |
| golog | 3361483 | 3589 ns/op | easy | common |
| zap | 2971119 | 4066 ns/op | complex | normal |
| logrus | 1553419 | 7869 ns/op | normal | normal |

> Environment:I7-6700HQ CPU @ 2.6 GHZ, 16 GB RAM
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

[![License](./license.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)

**logit** 是一个简单易用并且是基于级别控制的日志库,可以应用于所有的 [GoLang](https://golang.org) 应用程序中。
**logit** 是一个简单易用并且是基于级别控制和配置文件的日志库,可以应用于所有的 [GoLang](https://golang.org) 应用程序中。

[Read me in English](./README.en.md).

### 🥇 功能特性

* 独特的日志输出模块设计,使用 wrapper 和 handler 装载特定的模块,实现扩展功能
* 支持日志级别控制,一共有四个日志级别,分别是 debug,info,warn 和 error
* 支持配置文件,可以让用户在项目编译成二进制之后还能灵活地控制日志的设置
* 支持日志记录函数,使用回调的形式获取日志内容,对长日志内容的组织逻辑会更清晰
* 支持开启或者关闭日志功能,线上环境可以关闭或调高日志级别
* 支持记录日志到文件中,并且可以自定义日志文件名
Expand All @@ -22,8 +23,6 @@

_历史版本的特性请查看 [HISTORY.md](./HISTORY.md)。未来版本的新特性和计划请查看 [FUTURE.md](./FUTURE.md)_

> 未来的 v0.1.0 以及更高的版本将会做一次设计上的重构,尽可能保持代码的简洁和功能的易用性,更多信息请查看 v0.1.x 分支。
### 🚀 安装方式

唯一需要的依赖就是 [Golang 运行环境](https://golang.org).
Expand All @@ -42,7 +41,7 @@ module your_project_name
go 1.14

require (
github.com/FishGoddess/logit v0.1.1-alpha
github.com/FishGoddess/logit v0.1.2
)
```

Expand Down Expand Up @@ -92,6 +91,7 @@ func main() {
* [basic](./_examples/basic.go)
* [logger](./_examples/logger.go)
* [level_and_disable](./_examples/level_and_disable.go)
* [config_file](./_examples/config_file.go)
* [handler](./_examples/handler.go)
* [wrapper](./_examples/wrapper.go)
* [log_to_file](./_examples/log_to_file.go)
Expand All @@ -101,18 +101,17 @@ _更多使用案例请查看 [_examples](./_examples) 目录。_
### 🔥 性能测试

```bash
$ go test -v ./_examples/benchmarks_test.go -bench=. -benchtime=1s
$ go test -v ./_examples/benchmarks_test.go -bench=. -benchtime=10s
```

> 测试文件:[_examples/benchmarks_test.go](./_examples/benchmarks_test.go)
| 测试 | 单位时间内运行次数 (越大越好) | 每个操作消耗时间 (越小越好) | 功能性 | 扩展性 |
| -----------|--------|-------------|-------------|-------------|
| **logit** |   **667340** | **1844 ns/op** | 强大 ||
| zap |   401043 | 2793 ns/op | 正常 | 正常 |
| logrus |   158262 | 7751 ns/op | 正常 | 正常 |
| golog |   751064 | 1614 ns/op | 正常 | 正常 |
| golang log | 1269531 |   938 ns/op | 一般 ||
| **logit** | **6429907** | **1855 ns/op** | 强大 ||
| golog | 3361483 | 3589 ns/op | 简单 | 一般 |
| zap | 2971119 | 4066 ns/op | 复杂 | 正常 |
| logrus | 1553419 | 7869 ns/op | 正常 | 正常 |

> 测试环境:I7-6700HQ CPU @ 2.6 GHZ,16 GB RAM
Expand Down
Loading

0 comments on commit 7387004

Please sign in to comment.