first commit
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
target/
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# brick-common-log
|
||||||
|
|
||||||
|
日志模块 —— 提供统一的结构化日志封装。
|
||||||
|
|
||||||
|
## 变体
|
||||||
|
|
||||||
|
| 分支 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| `master` | 主分支 |
|
||||||
|
|
||||||
|
## 依赖
|
||||||
|
|
||||||
|
- `brick-common-core`
|
||||||
|
|
||||||
|
## 使用
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brick add log
|
||||||
|
```
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# brick-common-log 编码规范
|
||||||
|
|
||||||
|
## 职责边界
|
||||||
|
|
||||||
|
log 模块提供统一的结构化日志封装,业务代码通过 `LogUtil` 输出日志,不直接依赖 SLF4J/Logback。
|
||||||
|
|
||||||
|
## 使用准则
|
||||||
|
|
||||||
|
- 日志统一通过 `LogUtil` 输出。
|
||||||
|
- 关键操作(增删改、外部调用)必须记录结构化日志。
|
||||||
|
- 禁止在日志中输出密码、Token、手机号等敏感信息。
|
||||||
|
|
||||||
|
## 正例
|
||||||
|
|
||||||
|
```java
|
||||||
|
LogUtil.info("user.login", "userId", userId, "ip", ip);
|
||||||
|
```
|
||||||
|
|
||||||
|
## 反例
|
||||||
|
|
||||||
|
```java
|
||||||
|
// 直接使用 SLF4J
|
||||||
|
logger.info("user {} logged in from {}", userId, ip);
|
||||||
|
|
||||||
|
// 日志输出敏感信息
|
||||||
|
LogUtil.info("user.login", "password", password);
|
||||||
|
```
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
module: log
|
||||||
|
summary: 统一日志封装,提供结构化日志输出,屏蔽底层日志框架细节。
|
||||||
|
dos:
|
||||||
|
- 业务代码通过 LogUtil 输出日志,统一格式。
|
||||||
|
- 关键操作节点必须记录结构化日志(who / what / when / result)。
|
||||||
|
donts:
|
||||||
|
- 不要在业务代码中直接使用 SLF4J / Logback API。
|
||||||
|
- 日志中不要输出敏感信息(密码、Token 等)。
|
||||||
|
examples:
|
||||||
|
- path: src/main/java/{{basePkgPath}}/log/LogUtil.java
|
||||||
|
note: 日志工具入口。
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name: brick-common-log
|
||||||
|
version: 0.0.0
|
||||||
|
description: 日志模块,提供统一的结构化日志封装
|
||||||
|
language: java
|
||||||
|
defaultBranch: master
|
||||||
|
module: log
|
||||||
|
|
||||||
|
variants:
|
||||||
|
- branch: master
|
||||||
|
label: master
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: basePackage
|
||||||
|
required: true
|
||||||
|
- name: projectName
|
||||||
|
required: true
|
||||||
|
- name: javaVersion
|
||||||
|
required: true
|
||||||
|
- name: groupId
|
||||||
|
required: true
|
||||||
|
|
||||||
|
dependsOn:
|
||||||
|
- brick-common-core
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.synoth.brick</groupId>
|
||||||
|
<artifactId>brick-common-log</artifactId>
|
||||||
|
<version>0.0.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.synoth.brick</groupId>
|
||||||
|
<artifactId>brick-common-core</artifactId>
|
||||||
|
<version>0.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.synoth.brick.log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一日志工具,封装日志格式与输出。
|
||||||
|
*/
|
||||||
|
public final class LogUtil {
|
||||||
|
|
||||||
|
private LogUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: 提供结构化日志输出方法
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>{{groupId}}</groupId>
|
||||||
|
<artifactId>{{projectName}}-common-log</artifactId>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>{{javaVersion}}</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>{{groupId}}</groupId>
|
||||||
|
<artifactId>{{projectName}}-common-core</artifactId>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package {{basePackage}}.log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一日志工具,封装日志格式与输出。
|
||||||
|
*/
|
||||||
|
public final class LogUtil {
|
||||||
|
|
||||||
|
private LogUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: 提供结构化日志输出方法
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user