Skip to content

Commit fc7eab5

Browse files
committed
modify: readme
1 parent 0b196c1 commit fc7eab5

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ uv add pyhunt
4343

4444
## Quick Start
4545

46-
### 1. Set Up Environment Variable File
46+
### 1. Set Up and Manage Environment Variable File
47+
You can set up and manage the `.env` file by running the `hunt` command.
48+
4749
```bash
4850
hunt
4951
```
50-
This command sets `HUNT_LEVEL=DEBUG` in your `.env` file.
52+
53+
Executing the above command sets `HUNT_LEVEL=DEBUG` and `ROOT_DIR` to the current directory in the `.env` file.
5154

5255
### 2. Apply `@trace` to Functions or Classes
5356
See more examples in the [examples](https://github.com/pyhunt/pyhunt/tree/main/examples) folder.
@@ -115,6 +118,8 @@ logger.critical("This is a critical log.")
115118

116119
## CLI Usage
117120

121+
You can manage log levels and other settings using the `hunt` command.
122+
118123
```bash
119124
hunt [options]
120125
```
@@ -126,5 +131,16 @@ hunt [options]
126131
- `--warning` : WARNING level
127132
- `--error` : ERROR level
128133
- `--critical` : CRITICAL level
134+
- `--root` : Sets the `ROOT_DIR` environment variable to the current directory.
135+
- `--repeat <count>` : Sets the `HUNT_MAX_REPEAT` environment variable to the specified count. (Log repetition limit)
136+
137+
If no option is specified, the default is `DEBUG`.
138+
139+
### Environment Variables
140+
141+
`pyhunt` supports the following environment variables through the `.env` file:
129142

130-
If no option is specified, the default is `INFO`.
143+
- `HUNT_LEVEL`: Sets the log level (DEBUG, INFO, WARNING, ERROR, CRITICAL). Default is `DEBUG`.
144+
- `HUNT_MAX_REPEAT`: The number of times the same log is displayed when repeated. Default is 3.
145+
- `ELAPSED`: Sets whether to display function execution time in logs (`True` or `False`). Default is `True`.
146+
- `ROOT_DIR`: Sets the base directory for log output. Displays paths more accurately.

README_KR.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ uv add pyhunt
4646

4747
## 빠른 시작
4848

49-
### 1. 환경변수 파일 설정
49+
### 1. 환경변수 파일 설정 및 관리
50+
`hunt` 명령어를 실행하여 `.env` 파일을 설정하고 관리할 수 있습니다.
51+
5052
```bash
5153
hunt
5254
```
5355

54-
`.env` 파일에 `HUNT_LEVEL=DEBUG` 값이 설정됩니다.
56+
위 명령어를 실행하면 `.env` 파일에 `HUNT_LEVEL=DEBUG``ROOT_DIR`이 현재 디렉토리로 설정됩니다.
5557

5658

5759
### 2. 함수 또는 클래스에 `@trace` 적용
@@ -120,6 +122,8 @@ logger.critical("This is a critical log.")
120122

121123
## CLI 사용법
122124

125+
`hunt` 명령어를 사용하여 로그 레벨 및 기타 설정을 관리할 수 있습니다.
126+
123127
```bash
124128
hunt [옵션]
125129
```
@@ -131,8 +135,19 @@ hunt [옵션]
131135
- `--warning` : WARNING 레벨
132136
- `--error` : ERROR 레벨
133137
- `--critical` : CRITICAL 레벨
138+
- `--root` : `ROOT_DIR` 환경 변수를 현재 디렉토리로 설정합니다.
139+
- `--repeat <횟수>` : `HUNT_MAX_REPEAT` 환경 변수를 지정된 횟수로 설정합니다. (로그 반복 제한)
140+
141+
옵션 미지정 시 기본값은 `DEBUG`입니다.
142+
143+
### 환경 변수
144+
145+
`pyhunt``.env` 파일을 통해 다음 환경 변수를 지원합니다.
134146

135-
옵션 미지정 시 기본값은 `INFO`입니다.
147+
- `HUNT_LEVEL`: 로그 레벨 설정 (DEBUG, INFO, WARNING, ERROR, CRITICAL). 기본값은 `DEBUG`입니다.
148+
- `HUNT_MAX_REPEAT`: 동일한 로그가 반복될 때 표시를 제한하는 횟수입니다. 기본값은 3입니다.
149+
- `ELAPSED`: 로그에 함수 실행 시간을 표시할지 여부를 설정합니다. (`True` 또는 `False`). 기본값은 `True`입니다.
150+
- `ROOT_DIR`: 로그 출력 시 기준 디렉토리를 설정합니다. 보다 정확하게 경로를 표시합니다.
136151

137152

138153

pyhunt/decorator.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import inspect
33
import os
4+
import sys
45
import time
56
import traceback
67
from pathlib import Path
@@ -232,14 +233,11 @@ async def async_wrapper(*args, **kwargs):
232233
)
233234
return result
234235
except Exception as e:
235-
import sys as _sys_module
236-
import traceback as _traceback_module
237-
238-
full_tb_str = "".join(_traceback_module.format_exception(e))
236+
full_tb_str = "".join(traceback.format_exception(e))
239237
first_tb_str = extract_first_traceback(full_tb_str)
240238

241239
os.write(1, first_tb_str.encode())
242-
_sys_module.exit(1)
240+
sys.exit(1)
243241
finally:
244242
# Reset context after await completes
245243
if token_ctx is not None and token_depth is not None:
@@ -265,17 +263,11 @@ def wrapper(*args, **kwargs):
265263
)
266264
return result
267265
except Exception as e:
268-
# Filter traceback in the outermost frame
269-
# filtered_tb = _filter_traceback(e.__traceback__)
270-
271-
import sys as _sys_module
272-
import traceback as _traceback_module
273-
274-
full_tb_str = "".join(_traceback_module.format_exception(e))
266+
full_tb_str = "".join(traceback.format_exception(e))
275267
first_tb_str = extract_first_traceback(full_tb_str)
276268

277269
os.write(1, first_tb_str.encode())
278-
_sys_module.exit(1)
270+
sys.exit(1)
279271

280272
return async_wrapper if is_async else wrapper
281273

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
"Operating System :: OS Independent",
2121
]
2222
dependencies = ["dotenv>=0.9.9"]
23-
version = "1.1.1"
23+
version = "1.1.2"
2424

2525
[project.urls]
2626
source = "https://github.com/easydevv/pyhunt"

0 commit comments

Comments
 (0)