Skip to content

Commit 28f03c3

Browse files
committed
更新文档(docker-compose的部署说明,swag的安装方式,zap的使用与配置说明)
1 parent 3db0ced commit 28f03c3

File tree

2 files changed

+102
-11
lines changed

2 files changed

+102
-11
lines changed

README-en.md

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ We are excited that you are interested in contributing to gin-vue-admin. Before
134134
135135
- If the subnet is modified, the ipv4_address of each service needs to be modified, and the ip of the server on line 20 of [.docker-compose/nginx/conf.d/my.conf](.docker-compose/nginx/conf.d/my.conf) also needs to be modified
136136
137+
> <font color=red>**Use docker-compose to deploy this project need attention**</font>
138+
139+
- For mysql database, please use a local database installed on the server disk.
140+
- Avoid using mysql in the docker container, there may be write problems, io is lower than the host machine, docker's persistence mechanism problem
141+
- [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) is for docker-compose ==experience this project==, prohibit the use of [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) to initialize project data, Database initialization[Please use this method](https://www.gin-vue-admin.com/docs/help#step1%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%9D%E5%A7%8B%E5%8C%96)
142+
- Use [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) to initialize all problems, please bear it yourself, and have nothing to do with this project
143+
- When deploying using docker-compose of this project,Please modify the [nginx configuration](.docker-compose/nginx/conf.d/my.conf), mysql configuration, networks configuration, redis configuration corresponding to [docker-compose.yaml](./docker-compose.yaml), and make changes as needed.
144+
137145
### 2.1 Web
138146

139147
```bash
@@ -162,6 +170,47 @@ go list (go mod tidy)
162170
go build
163171
```
164172

173+
> Zap log library usage guide && configuration guide
174+
175+
The configuration of the Zap log library selects zap under [config.yaml](./server/config.yaml)
176+
177+
```yaml
178+
# zap logger configuration
179+
zap:
180+
level: 'debug'
181+
format: 'console'
182+
prefix: '[GIN-VUE-ADMIN]'
183+
director: 'log'
184+
link_name: 'latest_log'
185+
show_line: true
186+
encode_level: 'LowercaseColorLevelEncoder'
187+
stacktrace_key: 'stacktrace'
188+
log_in_console: true
189+
```
190+
191+
| Configuration Name | Type Of Configuration | Description |
192+
| ------------------ | --------------------- | ------------------------------------------------------------ |
193+
| level | string | For a detailed description of the level mode, please see the official [zap documentation](https://pkg.go.dev/go.uber.org/zap?tab=doc#pkg-constants) <br />info: info mode, stack information without errors, only output information<br />debug: debug mode, stack details with errors<br />warn:warn mode<br />error: error mode, stack details with error<br />dpanic: dpanic mode<br />panic: panic mode<br />fatal: fatal mode<br /> |
194+
| format | string | console: Output log in console format<br />json: json format output log |
195+
| prefix | string | Log prefix |
196+
| director | string | The folder to store the log can be modified, no need to create it manually |
197+
| link_name | string | [A soft connection file](https://baike.baidu.com/item/%E8%BD%AF%E9%93%BE%E6%8E%A5) of link_name will be generated in the server directory, and the link is the latest log file of the director configuration item |
198+
| show_line | bool | Display the line number, the default is true, it is not recommended to modify |
199+
| encode_level | string | LowercaseLevelEncoder: lowercase<br /> LowercaseColorLevelEncoder: lowercase with color<br />CapitalLevelEncoder: uppercase<br />CapitalColorLevelEncoder: uppercase with color |
200+
| stacktrace_key | string | The name of the stack, that is, the key of josn when outputting the log in json format |
201+
| log_in_console | bool | Whether to output to the console, the default is true |
202+
203+
- Development environment || Debug environment configuration recommendations
204+
- `level:debug`
205+
- `format:console`
206+
- `encode_level:LowercaseColorLevelEncoder`或者`encode_leve:CapitalColorLevelEncoder`
207+
- Deployment environment configuration recommendations
208+
- `level:error`
209+
- `format:json`
210+
- `encode_level: LowercaseLevelEncoder `或者 `encode_level:CapitalLevelEncoder`
211+
- `log_in_console: false`
212+
- <font color=red>Suggestions are only suggestions, you can proceed according to your own needs, and suggestions are for reference only</font>
213+
165214
### 2.3 API docs auto-generation using swagger
166215

167216
#### 2.3.1 install swagger
@@ -176,7 +225,6 @@ go get -u github.com/swaggo/swag/cmd/swag
176225
In mainland China, access to go.org/x is prohibited,we recommend [goproxy.io](https://goproxy.io/zh/)
177226

178227
````bash
179-
180228
If you are using Go version 1.13 and above (recommended)
181229
# Enable Go Modules function
182230
go env -w GO111MODULE=on
@@ -186,11 +234,8 @@ If you are using Go version 1.12 and below
186234
go env -w GO111MODULE=on
187235
go env -w GOPROXY=https://goproxy.io
188236

189-
# get swag
190-
go get -g -v github.com/swaggo/swag/cmd/swag
191-
192-
# cd GOPATH/src/github.com/swaggo/swag/cmd/swag
193-
go install
237+
# Use the following command to download swag
238+
go get -u github.com/swaggo/swag/cmd/swag
194239
````
195240

196241
#### 2.3.2 API docs generation

README.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm
130130

131131
- 如果修改了子网,对应的每个service的ipv4_address都需要修改,还有[.docker-compose/nginx/conf.d/my.conf](./.docker-compose/nginx/conf.d/my.conf)的第20行的server的ip也需要修改
132132

133+
> <font color=red>**使用docker-compose进行部署本项目需注意的问题**</font>
134+
135+
- mysql数据库请使用装在服务器磁盘的本地数据库.
136+
- 避免使用docker容器内的mysql,可能会出现写入的问题, io比宿主机低 docker的持久化机制问题
137+
- [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)是给docker-compose进行<font color=red>体验本项目</font>的, 禁止[init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)使用进行项目数据的初始化, 数据库初始化[请使用此方法](https://www.gin-vue-admin.com/docs/help#step1%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%9D%E5%A7%8B%E5%8C%96)
138+
- 使用[init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)进行初始化出现的所有问题,请自行承担,与本项目无关
139+
- 使用本项目的docker-compose进行部署时,请修改[docker-compose.yaml](./docker-compose.yaml)对应的[nginx配置](.docker-compose/nginx/conf.d/my.conf),mysql配置,networks配置,redis配置,按需自行更改.
140+
133141
### 2.1 web端
134142

135143
```bash
@@ -158,6 +166,47 @@ go list (go mod tidy)
158166
go build
159167
```
160168

169+
> Zap日志库使用指南&&配置指南
170+
171+
Zap日志库的配置选择在[config.yaml](./server/config.yaml)下的zap
172+
173+
```yaml
174+
# zap logger configuration
175+
zap:
176+
level: 'debug'
177+
format: 'console'
178+
prefix: '[GIN-VUE-ADMIN]'
179+
director: 'log'
180+
link_name: 'latest_log'
181+
show_line: true
182+
encode_level: 'LowercaseColorLevelEncoder'
183+
stacktrace_key: 'stacktrace'
184+
log_in_console: true
185+
```
186+
187+
| 配置名 | 配置的类型 | 说明 |
188+
| -------------- | ---------- | ------------------------------------------------------------ |
189+
| level | string | level的模式的详细说明,请看[zap官方文档](https://pkg.go.dev/go.uber.org/zap?tab=doc#pkg-constants) <br />info: info模式,无错误的堆栈信息,只输出信息<br />debug:debug模式,有错误的堆栈详细信息<br />warn:warn模式<br />error: error模式,有错误的堆栈详细信息<br />dpanic: dpanic模式<br />panic: panic模式<br />fatal: fatal模式<br /> |
190+
| format | string | console: 控制台形式输出日志<br />json: json格式输出日志 |
191+
| prefix | string | 日志的前缀 |
192+
| director | string | 存放日志的文件夹,修改即可,不需要手动创建 |
193+
| link_name | string | 在server目录下会生成一个link_name的[软连接文件](https://baike.baidu.com/item/%E8%BD%AF%E9%93%BE%E6%8E%A5),链接的是director配置项的最新日志文件 |
194+
| show_line | bool | 显示行号, 默认为true,不建议修改 |
195+
| encode_level | string | LowercaseLevelEncoder:小写<br /> LowercaseColorLevelEncoder:小写带颜色<br />CapitalLevelEncoder: 大写<br />CapitalColorLevelEncoder: 大写带颜色 |
196+
| stacktrace_key | string | 堆栈的名称,即在json格式输出日志时的josn的key |
197+
| log_in_console | bool | 是否输出到控制台,默认为true |
198+
199+
- 开发环境 || 调试环境配置建议
200+
- `level:debug`
201+
- `format:console`
202+
- `encode_level:LowercaseColorLevelEncoder`或者`encode_leve:CapitalColorLevelEncoder`
203+
- 部署环境配置建议
204+
- `level:error`
205+
- `format:json`
206+
- `encode_level: LowercaseLevelEncoder `或者 `encode_level:CapitalLevelEncoder`
207+
- `log_in_console: false`
208+
- <font color=red>建议只是建议,按照自己的需求进行即可,给出建议仅供参考</font>
209+
161210
### 2.3 swagger自动化API文档
162211

163212
#### 2.3.1 安装 swagger
@@ -178,11 +227,8 @@ go env -w GO111MODULE=on
178227
# 配置 GOPROXY 环境变量
179228
go env -w GOPROXY=https://goproxy.io,direct
180229
181-
# 执行
182-
go get -g -v github.com/swaggo/swag/cmd/swag
183-
184-
# 到GOPATH的/src/github.com/swaggo/swag/cmd/swag路径下执行
185-
go install
230+
# 使用如下命令下载swag
231+
go get -u github.com/swaggo/swag/cmd/swag
186232
```
187233

188234
#### 2.3.2 生成API文档

0 commit comments

Comments
 (0)