Skip to content

Commit c087492

Browse files
committed
first commit
0 parents  commit c087492

File tree

18 files changed

+1550
-0
lines changed

18 files changed

+1550
-0
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 'lts/*'
22+
23+
- name: Install dependencies
24+
run: npm install -g conventional-changelog-conventionalcommits @semantic-release/git semantic-release
25+
26+
- name: Release
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
npx semantic-release --branches main

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.idea
2+
.ipynb_checkpoints
3+
.mypy_cache
4+
.vscode
5+
__pycache__
6+
.pytest_cache
7+
htmlcov
8+
dist
9+
logs
10+
site
11+
.coverage*
12+
coverage.xml
13+
.netlify
14+
test.db
15+
log.txt
16+
Pipfile.lock
17+
env3.*
18+
env
19+
docs_build
20+
site_build
21+
venv
22+
docs.zip
23+
archive.zip
24+
25+
# vim temporary files
26+
*~
27+
.*.sw?
28+
.cache
29+
30+
# macOS
31+
.DS_Store
32+
Python-3.13.1
33+
dist
34+
Python-3.13.1.tar.xz

.releaserc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"plugins": [
6+
"@semantic-release/commit-analyzer",
7+
"@semantic-release/release-notes-generator",
8+
"@semantic-release/github"
9+
]
10+
}

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

README.md

Lines changed: 338 additions & 0 deletions
Large diffs are not rendered by default.

assets/zlogger-logo.svg

Lines changed: 34 additions & 0 deletions
Loading

examples/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from zlogger_kit.zlog import ZLog
2+
3+
__all__ = ["ZLog"]

examples/example1.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from zlogger_kit.zlog import ZLog
2+
from zlogger_kit.models import ZLogConfig
3+
from examples.modules import Module
4+
5+
config = ZLogConfig(
6+
module=Module.AUTH.value,
7+
json_format=False,
8+
log_path="logs/auth",
9+
)
10+
logger = ZLog.init(config)
11+
12+
logger.info("Starting authentication process", client_ip="192.168.1.100")
13+
logger.info("Login successful", user_id="user_123")
14+
logger.error(
15+
"Login failed",
16+
username="suspicious_user",
17+
ip="10.0.0.5",
18+
reason="Invalid credentials",
19+
)
20+
logger.warn(
21+
"Failed login attempt",
22+
username="suspicious_user",
23+
ip="10.0.0.5",
24+
reason="Invalid credentials",
25+
)
26+
logger.debug("Debug message", user_id="user_123")
27+
logger.warn(
28+
"Failed login attempt",
29+
username="suspicious_user",
30+
ip="10.0.0.5",
31+
reason="Invalid credentials",
32+
)

examples/example2.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from fastapi import FastAPI
2+
from examples.modules import Module
3+
from zlogger_kit.middleware import ZLogMiddleware
4+
from zlogger_kit.zlog import ZLog
5+
from zlogger_kit.models import ZLogConfig
6+
from examples.routers.payment_router import router as payment_router
7+
8+
app = FastAPI(title="Payment Service", description="API for payment processing")
9+
10+
zlogger = ZLog.init(
11+
ZLogConfig(
12+
module=Module.PAYMENT.value,
13+
log_path="logs",
14+
time_zone="Asia/Riyadh",
15+
json_format=True,
16+
)
17+
)
18+
19+
app.add_middleware(ZLogMiddleware, logger=zlogger)
20+
21+
app.include_router(payment_router)
22+
23+
24+
@app.get("/health")
25+
async def health():
26+
"""Health check endpoint"""
27+
return {"status": "healthy"}
28+
29+
30+
@app.get("/")
31+
async def root():
32+
return {"message": "Welcome to the Payment Service API 💸"}

examples/modules.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from enum import Enum
2+
3+
4+
class Module(str, Enum):
5+
AUTH = "AUTH"
6+
DATABASE = "DATABASE"
7+
CACHE = "CACHE"
8+
NETWORK = "NETWORK"
9+
PAYMENT = "PAYMENT"
10+
REGISTRATION = "REGISTRATION"
11+
SECURITY = "SECURITY"

0 commit comments

Comments
 (0)