Skip to content

Commit 9a3d238

Browse files
committed
chore: add log check step in precommit
Signed-off-by: Mustafa Elbehery <[email protected]>
1 parent e3928e6 commit 9a3d238

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,25 @@ repos:
146146
require_serial: true
147147
files: ^.github/workflows/.*$
148148

149+
- id: check-log-usage
150+
name: Check for proper log usage (use llama_stack.log instead)
151+
entry: bash
152+
language: system
153+
types: [python]
154+
pass_filenames: true
155+
args:
156+
- -c
157+
- |
158+
matches=$(grep -EnH '^[^#]*\b(impor\s+logging|from\s+logging\b)' "$@" | grep -v -e '#\s*allow-direct-logging' || true)
159+
if [ -n "$matches" ]; then
160+
# GitHub Actions annotation format
161+
while IFS=: read -r file line_num rest; do
162+
echo "::error file=$file,line=$line_num::Do not use 'import logging' or 'from logging import' in $file. Use the custom log instead: from llama_stack.log import get_logger; logger = get_logger(). If direct logging is truly needed, add: # allow-direct-logging"
163+
done <<< "$matches"
164+
exit 1
165+
fi
166+
exit 0
167+
149168
ci:
150169
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
151170
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate

0 commit comments

Comments
 (0)