From 568cb6bcd4ad026758002c9db64a22c415db270f Mon Sep 17 00:00:00 2001 From: yangzhaohan Date: Mon, 22 Jun 2026 15:53:41 +0800 Subject: [PATCH] first commit --- .gitignore | 1 + README.md | 19 ++++++++++ ai/conventions.md | 27 ++++++++++++++ ai/module.yaml | 11 ++++++ manifest.yaml | 23 ++++++++++++ pom.xml | 31 ++++++++++++++++ .../java/com/synoth/brick/log/LogUtil.java | 13 +++++++ template/pom.xml | 35 +++++++++++++++++++ .../java/{{basePkgPath}}/log/LogUtil.java | 13 +++++++ 9 files changed, 173 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 ai/conventions.md create mode 100644 ai/module.yaml create mode 100644 manifest.yaml create mode 100644 pom.xml create mode 100644 src/main/java/com/synoth/brick/log/LogUtil.java create mode 100644 template/pom.xml create mode 100644 template/src/main/java/{{basePkgPath}}/log/LogUtil.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f97022 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a9c3aac --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# brick-common-log + +日志模块 —— 提供统一的结构化日志封装。 + +## 变体 + +| 分支 | 说明 | +|------|------| +| `master` | 主分支 | + +## 依赖 + +- `brick-common-core` + +## 使用 + +```bash +brick add log +``` diff --git a/ai/conventions.md b/ai/conventions.md new file mode 100644 index 0000000..91212b2 --- /dev/null +++ b/ai/conventions.md @@ -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); +``` diff --git a/ai/module.yaml b/ai/module.yaml new file mode 100644 index 0000000..fc03636 --- /dev/null +++ b/ai/module.yaml @@ -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: 日志工具入口。 diff --git a/manifest.yaml b/manifest.yaml new file mode 100644 index 0000000..14ad0fc --- /dev/null +++ b/manifest.yaml @@ -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 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4f85fe7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + com.synoth.brick + brick-common-log + 0.0.0-SNAPSHOT + jar + + + org.springframework.boot + spring-boot-starter-parent + 3.4.0 + + + + + 17 + + + + + com.synoth.brick + brick-common-core + 0.0.0-SNAPSHOT + + + + diff --git a/src/main/java/com/synoth/brick/log/LogUtil.java b/src/main/java/com/synoth/brick/log/LogUtil.java new file mode 100644 index 0000000..0bc30be --- /dev/null +++ b/src/main/java/com/synoth/brick/log/LogUtil.java @@ -0,0 +1,13 @@ +package com.synoth.brick.log; + +/** + * 统一日志工具,封装日志格式与输出。 + */ +public final class LogUtil { + + private LogUtil() { + } + + // TODO: 提供结构化日志输出方法 + +} diff --git a/template/pom.xml b/template/pom.xml new file mode 100644 index 0000000..bfac0a3 --- /dev/null +++ b/template/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + {{groupId}} + {{projectName}}-common-log + 0.0.0 + jar + + + org.springframework.boot + spring-boot-starter-parent + 3.4.0 + + + + + {{javaVersion}} + + + + + {{groupId}} + {{projectName}}-common-core + 0.0.0 + + + org.springframework.boot + spring-boot-starter + + + + diff --git a/template/src/main/java/{{basePkgPath}}/log/LogUtil.java b/template/src/main/java/{{basePkgPath}}/log/LogUtil.java new file mode 100644 index 0000000..a3d1e6f --- /dev/null +++ b/template/src/main/java/{{basePkgPath}}/log/LogUtil.java @@ -0,0 +1,13 @@ +package {{basePackage}}.log; + +/** + * 统一日志工具,封装日志格式与输出。 + */ +public final class LogUtil { + + private LogUtil() { + } + + // TODO: 提供结构化日志输出方法 + +}