ezlog-py 1.0.1__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ezlog_py-1.0.2/PKG-INFO +68 -0
- ezlog_py-1.0.2/README.md +57 -0
- {ezlog_py-1.0.1 → ezlog_py-1.0.2}/pyproject.toml +1 -1
- ezlog_py-1.0.2/src/ezlog/__init__.py +71 -0
- {ezlog_py-1.0.1 → ezlog_py-1.0.2}/src/ezlog/ezlog.py +30 -66
- ezlog_py-1.0.1/PKG-INFO +0 -72
- ezlog_py-1.0.1/README.md +0 -61
- ezlog_py-1.0.1/src/ezlog/__init__.py +0 -54
- {ezlog_py-1.0.1 → ezlog_py-1.0.2}/src/ezlog/types.py +0 -0
ezlog_py-1.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: ezlog-py
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Simple, performant logging with ANSI colors for Python.
|
|
5
|
+
Author: eaannist
|
|
6
|
+
Author-email: eaannist <eaannist@gmail.com>
|
|
7
|
+
Requires-Dist: pytest>=8.0.0 ; extra == 'dev'
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# ezlog
|
|
13
|
+
|
|
14
|
+
Simple, performant logging with ANSI colors for Python.
|
|
15
|
+
Published on PyPI as **ezlog-py** (import as `ezlog`).
|
|
16
|
+
|
|
17
|
+
- **5 levels**: `error`, `warn`, `info`, `success`, `debug` (no NOTSET/CRITICAL)
|
|
18
|
+
- **Short aliases**: `e`, `w`, `i`, `s`, `d`
|
|
19
|
+
- **ANSI colors**: red, yellow, cyan, green, magenta
|
|
20
|
+
- **Stdlib integration**: after `init()`, `logging.info()` etc. go through ezlog formatting
|
|
21
|
+
- **Zero dependencies**
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install ezlog-py
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Import only ezlog, call **init** with the two settings, then use **ezlog.log** or stdlib **logging** (both go through ezlog):
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import ezlog
|
|
35
|
+
|
|
36
|
+
ezlog.init(use_colors=True, use_timestamp=True)
|
|
37
|
+
|
|
38
|
+
# Direct ezlog (includes .success() level)
|
|
39
|
+
ezlog.log.success("Application started")
|
|
40
|
+
ezlog.log.info("Environment: dev")
|
|
41
|
+
ezlog.log.w("Warning")
|
|
42
|
+
ezlog.log.e("Error")
|
|
43
|
+
ezlog.log.d("Debug")
|
|
44
|
+
|
|
45
|
+
# Stdlib logging (wired internally; same formatting)
|
|
46
|
+
import logging
|
|
47
|
+
logging.info("Hello from stdlib")
|
|
48
|
+
logging.error("Something failed", exc_info=True)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## init (two settings)
|
|
52
|
+
|
|
53
|
+
| Argument | Default | Description |
|
|
54
|
+
|----------------|--------|-----------------|
|
|
55
|
+
| `use_colors` | `True` | ANSI colors |
|
|
56
|
+
| `use_timestamp`| `True` | ISO timestamp |
|
|
57
|
+
|
|
58
|
+
## Levels
|
|
59
|
+
|
|
60
|
+
Ezlog has 5 levels: **error**, **warn**, **info**, **success**, **debug**.
|
|
61
|
+
Stdlib DEBUG/INFO/WARNING/ERROR are mapped to ezlog; NOTSET is skipped, CRITICAL is treated as error.
|
|
62
|
+
|
|
63
|
+
## Exports
|
|
64
|
+
|
|
65
|
+
- `init(use_colors=..., use_timestamp=...)` – initialize and wire to stdlib logging
|
|
66
|
+
- `log` – EzLog instance (set after `init()`); use for direct logging and `.success()`
|
|
67
|
+
- `EzLog` – logger class (for custom instances)
|
|
68
|
+
- Types: `LogLevel`, `LogColors`, `EzlogConfig`, `LevelsConfig`, `LevelConfig`, `LogArgs`, `ConsoleMethod`
|
ezlog_py-1.0.2/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# ezlog
|
|
2
|
+
|
|
3
|
+
Simple, performant logging with ANSI colors for Python.
|
|
4
|
+
Published on PyPI as **ezlog-py** (import as `ezlog`).
|
|
5
|
+
|
|
6
|
+
- **5 levels**: `error`, `warn`, `info`, `success`, `debug` (no NOTSET/CRITICAL)
|
|
7
|
+
- **Short aliases**: `e`, `w`, `i`, `s`, `d`
|
|
8
|
+
- **ANSI colors**: red, yellow, cyan, green, magenta
|
|
9
|
+
- **Stdlib integration**: after `init()`, `logging.info()` etc. go through ezlog formatting
|
|
10
|
+
- **Zero dependencies**
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install ezlog-py
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Import only ezlog, call **init** with the two settings, then use **ezlog.log** or stdlib **logging** (both go through ezlog):
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import ezlog
|
|
24
|
+
|
|
25
|
+
ezlog.init(use_colors=True, use_timestamp=True)
|
|
26
|
+
|
|
27
|
+
# Direct ezlog (includes .success() level)
|
|
28
|
+
ezlog.log.success("Application started")
|
|
29
|
+
ezlog.log.info("Environment: dev")
|
|
30
|
+
ezlog.log.w("Warning")
|
|
31
|
+
ezlog.log.e("Error")
|
|
32
|
+
ezlog.log.d("Debug")
|
|
33
|
+
|
|
34
|
+
# Stdlib logging (wired internally; same formatting)
|
|
35
|
+
import logging
|
|
36
|
+
logging.info("Hello from stdlib")
|
|
37
|
+
logging.error("Something failed", exc_info=True)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## init (two settings)
|
|
41
|
+
|
|
42
|
+
| Argument | Default | Description |
|
|
43
|
+
|----------------|--------|-----------------|
|
|
44
|
+
| `use_colors` | `True` | ANSI colors |
|
|
45
|
+
| `use_timestamp`| `True` | ISO timestamp |
|
|
46
|
+
|
|
47
|
+
## Levels
|
|
48
|
+
|
|
49
|
+
Ezlog has 5 levels: **error**, **warn**, **info**, **success**, **debug**.
|
|
50
|
+
Stdlib DEBUG/INFO/WARNING/ERROR are mapped to ezlog; NOTSET is skipped, CRITICAL is treated as error.
|
|
51
|
+
|
|
52
|
+
## Exports
|
|
53
|
+
|
|
54
|
+
- `init(use_colors=..., use_timestamp=...)` – initialize and wire to stdlib logging
|
|
55
|
+
- `log` – EzLog instance (set after `init()`); use for direct logging and `.success()`
|
|
56
|
+
- `EzLog` – logger class (for custom instances)
|
|
57
|
+
- Types: `LogLevel`, `LogColors`, `EzlogConfig`, `LevelsConfig`, `LevelConfig`, `LogArgs`, `ConsoleMethod`
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ezlog: simple, performant logging with ANSI colors (Python port of ezlog).
|
|
3
|
+
Install as ezlog-py from PyPI. Import ezlog, call init(use_colors, use_timestamp),
|
|
4
|
+
then use ezlog.log or stdlib logging; both go through ezlog formatting.
|
|
5
|
+
5 levels: error, warn, info, success, debug (no NOTSET/CRITICAL).
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
|
|
11
|
+
from ezlog.ezlog import EzLog, _EzLogHandler
|
|
12
|
+
from ezlog.types import (
|
|
13
|
+
ConsoleMethod,
|
|
14
|
+
EzlogConfig,
|
|
15
|
+
LevelConfig,
|
|
16
|
+
LevelsConfig,
|
|
17
|
+
LogArgs,
|
|
18
|
+
LogColors,
|
|
19
|
+
LogLevel,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"EzLog",
|
|
24
|
+
"init",
|
|
25
|
+
"log",
|
|
26
|
+
"LogLevel",
|
|
27
|
+
"LogColors",
|
|
28
|
+
"EzlogConfig",
|
|
29
|
+
"LevelsConfig",
|
|
30
|
+
"LevelConfig",
|
|
31
|
+
"LogArgs",
|
|
32
|
+
"ConsoleMethod",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
# Set by init(); use ezlog.log after calling ezlog.init().
|
|
36
|
+
log: EzLog | None = None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def init(
|
|
40
|
+
*,
|
|
41
|
+
use_colors: bool = True,
|
|
42
|
+
use_timestamp: bool = True,
|
|
43
|
+
) -> EzLog:
|
|
44
|
+
"""
|
|
45
|
+
Initialize ezlog and wire it to stdlib logging. Call once at startup.
|
|
46
|
+
After init(), use ezlog.log for direct logging (including .success()) or
|
|
47
|
+
logging.info() / logger.error() etc.; all go through ezlog formatting.
|
|
48
|
+
"""
|
|
49
|
+
global log
|
|
50
|
+
log = EzLog({
|
|
51
|
+
"useColors": use_colors,
|
|
52
|
+
"useTimestamp": use_timestamp,
|
|
53
|
+
})
|
|
54
|
+
root = logging.getLogger()
|
|
55
|
+
root.addHandler(_EzLogHandler(log))
|
|
56
|
+
root.setLevel(logging.DEBUG)
|
|
57
|
+
return log
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def main() -> None:
|
|
61
|
+
"""CLI entry point: init + short demo."""
|
|
62
|
+
init(use_colors=True, use_timestamp=True)
|
|
63
|
+
assert log is not None
|
|
64
|
+
log.success("Application started")
|
|
65
|
+
log.info("Environment: dev")
|
|
66
|
+
log.w("Warning message")
|
|
67
|
+
log.e("Error message")
|
|
68
|
+
log.d("Debug message")
|
|
69
|
+
log.info("User data:", {"id": 1, "name": "John"})
|
|
70
|
+
log.configure({"useTimestamp": False})
|
|
71
|
+
log.s("Done")
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"""
|
|
2
2
|
EzLog: simple, performant logging with ANSI colors.
|
|
3
|
-
Mirrors ezlog (TypeScript) API: 5 levels,
|
|
3
|
+
Mirrors ezlog (TypeScript) API: 5 levels (error, warn, info, success, debug).
|
|
4
|
+
Integrates with stdlib logging internally via init(); no NOTSET/CRITICAL.
|
|
4
5
|
"""
|
|
5
6
|
from __future__ import annotations
|
|
6
7
|
|
|
7
8
|
import json
|
|
8
|
-
import
|
|
9
|
+
import logging
|
|
9
10
|
import re
|
|
10
11
|
import sys
|
|
11
12
|
import traceback
|
|
12
13
|
from datetime import datetime
|
|
13
|
-
from typing import Any
|
|
14
|
+
from typing import Any
|
|
14
15
|
|
|
15
16
|
from ezlog.types import EzlogConfig, LevelConfig, LogLevel
|
|
16
17
|
|
|
18
|
+
# Stdlib level -> ezlog level. We do not use NOTSET or CRITICAL (CRITICAL -> error).
|
|
19
|
+
_STDLIB_LEVEL_MAP = {
|
|
20
|
+
logging.DEBUG: "debug",
|
|
21
|
+
logging.INFO: "info",
|
|
22
|
+
logging.WARNING: "warn",
|
|
23
|
+
logging.ERROR: "error",
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
# Compiled regex for stack line formatting (path:line:col).
|
|
18
27
|
_STACK_PATH_LINE_RE = re.compile(r"(\(?)([^\s()]+):(\d+):(\d+)(\)?)")
|
|
19
28
|
_STACK_FILE_RE = re.compile(r"^\s*File\s*")
|
|
@@ -351,69 +360,24 @@ class EzLog:
|
|
|
351
360
|
return self._colors["white"]
|
|
352
361
|
|
|
353
362
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
_IS_PRODUCTION = os.environ.get("ENV", "").lower() == "production"
|
|
357
|
-
|
|
358
|
-
_log = EzLog(
|
|
359
|
-
{
|
|
360
|
-
"levels": {
|
|
361
|
-
"error": True,
|
|
362
|
-
"warn": True,
|
|
363
|
-
"info": True,
|
|
364
|
-
"success": True,
|
|
365
|
-
"debug": not _IS_PRODUCTION,
|
|
366
|
-
},
|
|
367
|
-
"useColors": True,
|
|
368
|
-
"useLevels": True,
|
|
369
|
-
"useSymbols": True,
|
|
370
|
-
"useTimestamp": True,
|
|
371
|
-
}
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
def _default_is_http_error(err: Any) -> bool:
|
|
376
|
-
"""True if err has status_code or statusCode (common HTTP error pattern)."""
|
|
377
|
-
return hasattr(err, "status_code") or hasattr(err, "statusCode")
|
|
378
|
-
|
|
363
|
+
class _EzLogHandler(logging.Handler):
|
|
364
|
+
"""Internal handler: forwards stdlib LogRecords to EzLog. Skips NOTSET; CRITICAL -> error."""
|
|
379
365
|
|
|
380
|
-
def
|
|
381
|
-
|
|
382
|
-
|
|
366
|
+
def __init__(self, ezlog: EzLog) -> None:
|
|
367
|
+
super().__init__()
|
|
368
|
+
self._ezlog = ezlog
|
|
383
369
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
"""
|
|
395
|
-
is_http = is_http_error or _default_is_http_error
|
|
396
|
-
get_m = get_method or (
|
|
397
|
-
lambda req: getattr(req, "method", getattr(req, "METHOD", "?"))
|
|
398
|
-
)
|
|
399
|
-
get_u = get_url or (
|
|
400
|
-
lambda req: getattr(req, "url", getattr(req, "path", "?"))
|
|
401
|
-
)
|
|
402
|
-
|
|
403
|
-
def handler(err: Any, request: Any = None) -> None:
|
|
404
|
-
if request is None:
|
|
405
|
-
method, url = "?", "?"
|
|
406
|
-
else:
|
|
407
|
-
method, url = get_m(request), get_u(request)
|
|
408
|
-
if is_http(err):
|
|
409
|
-
code = _default_status_code(err)
|
|
410
|
-
if code >= 500:
|
|
411
|
-
_log.e(f"[{method}] {url} - {code}", err)
|
|
412
|
-
elif code >= 400:
|
|
413
|
-
_log.w(f"[{method}] {url} - {code}", err)
|
|
370
|
+
def emit(self, record: logging.LogRecord) -> None:
|
|
371
|
+
if record.levelno == logging.NOTSET:
|
|
372
|
+
return
|
|
373
|
+
level_name = _STDLIB_LEVEL_MAP.get(record.levelno)
|
|
374
|
+
if level_name is None:
|
|
375
|
+
level_name = "error" # CRITICAL and any unknown -> error
|
|
376
|
+
try:
|
|
377
|
+
msg = self.format(record)
|
|
378
|
+
if record.exc_info and record.exc_info[1] is not None:
|
|
379
|
+
self._ezlog._log(level_name, msg, record.exc_info[1])
|
|
414
380
|
else:
|
|
415
|
-
_log
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return handler
|
|
381
|
+
self._ezlog._log(level_name, msg)
|
|
382
|
+
except Exception: # noqa: BLE001
|
|
383
|
+
self.handleError(record)
|
ezlog_py-1.0.1/PKG-INFO
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: ezlog-py
|
|
3
|
-
Version: 1.0.1
|
|
4
|
-
Summary: Simple, performant logging with ANSI colors for Python.
|
|
5
|
-
Author: eaannist
|
|
6
|
-
Author-email: eaannist <eaannist@gmail.com>
|
|
7
|
-
Requires-Dist: pytest>=8.0.0 ; extra == 'dev'
|
|
8
|
-
Requires-Python: >=3.12
|
|
9
|
-
Provides-Extra: dev
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
|
|
12
|
-
# ezlog (Python)
|
|
13
|
-
|
|
14
|
-
Simple, performant logging with ANSI colors for Python.
|
|
15
|
-
Published on PyPI as **ezlog-py** (import as `ezlog`).
|
|
16
|
-
|
|
17
|
-
- **5 levels**: `error`, `warn`, `info`, `success`, `debug`
|
|
18
|
-
- **Short aliases**: `e`, `w`, `i`, `s`, `d`
|
|
19
|
-
- **ANSI colors**: red, yellow, cyan, green, magenta
|
|
20
|
-
- **Config**: levels on/off, colors, symbols vs text, timestamp
|
|
21
|
-
- **Safe serialization**: circular refs, dates, exceptions
|
|
22
|
-
- **Zero dependencies**
|
|
23
|
-
|
|
24
|
-
## Install
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
pip install ezlog-py
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Usage
|
|
31
|
-
|
|
32
|
-
```python
|
|
33
|
-
from ezlog import EzLog, create_error_handler
|
|
34
|
-
|
|
35
|
-
# Create your own logger (no pre-initialized log instance)
|
|
36
|
-
logger = EzLog({
|
|
37
|
-
"levels": {"error": True, "warn": True, "info": True, "success": True, "debug": False},
|
|
38
|
-
"useColors": True,
|
|
39
|
-
"useLevels": True,
|
|
40
|
-
"useSymbols": False,
|
|
41
|
-
"useTimestamp": True,
|
|
42
|
-
})
|
|
43
|
-
logger.success("Application started")
|
|
44
|
-
logger.info("Environment: dev")
|
|
45
|
-
logger.w("Warning")
|
|
46
|
-
logger.e("Error")
|
|
47
|
-
logger.d("Debug")
|
|
48
|
-
|
|
49
|
-
logger.configure({"useTimestamp": False})
|
|
50
|
-
logger.info("User:", {"id": 1, "name": "John"})
|
|
51
|
-
logger.error("Failed", Exception("Connection failed"))
|
|
52
|
-
|
|
53
|
-
# Error handler for routers (e.g. FastAPI/Starlette)
|
|
54
|
-
on_error = create_error_handler()
|
|
55
|
-
on_error(exception, request)
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Config
|
|
59
|
-
|
|
60
|
-
| Option | Description |
|
|
61
|
-
|----------------|----------------------------------------|
|
|
62
|
-
| `levels` | Enable/disable per level |
|
|
63
|
-
| `useColors` | ANSI colors on/off |
|
|
64
|
-
| `useLevels` | Show level label before message |
|
|
65
|
-
| `useSymbols` | Use symbols (x, !, i, ✓, d) or text |
|
|
66
|
-
| `useTimestamp`| ISO timestamp before message |
|
|
67
|
-
|
|
68
|
-
## Exports
|
|
69
|
-
|
|
70
|
-
- `EzLog` – logger class (create instances yourself)
|
|
71
|
-
- `create_error_handler(is_http_error=..., get_method=..., get_url=...)` – for router error callbacks
|
|
72
|
-
- Types: `LogLevel`, `LogColors`, `EzlogConfig`, `LevelsConfig`, `LevelConfig`, `LogArgs`, `ConsoleMethod`
|
ezlog_py-1.0.1/README.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# ezlog (Python)
|
|
2
|
-
|
|
3
|
-
Simple, performant logging with ANSI colors for Python.
|
|
4
|
-
Published on PyPI as **ezlog-py** (import as `ezlog`).
|
|
5
|
-
|
|
6
|
-
- **5 levels**: `error`, `warn`, `info`, `success`, `debug`
|
|
7
|
-
- **Short aliases**: `e`, `w`, `i`, `s`, `d`
|
|
8
|
-
- **ANSI colors**: red, yellow, cyan, green, magenta
|
|
9
|
-
- **Config**: levels on/off, colors, symbols vs text, timestamp
|
|
10
|
-
- **Safe serialization**: circular refs, dates, exceptions
|
|
11
|
-
- **Zero dependencies**
|
|
12
|
-
|
|
13
|
-
## Install
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pip install ezlog-py
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
```python
|
|
22
|
-
from ezlog import EzLog, create_error_handler
|
|
23
|
-
|
|
24
|
-
# Create your own logger (no pre-initialized log instance)
|
|
25
|
-
logger = EzLog({
|
|
26
|
-
"levels": {"error": True, "warn": True, "info": True, "success": True, "debug": False},
|
|
27
|
-
"useColors": True,
|
|
28
|
-
"useLevels": True,
|
|
29
|
-
"useSymbols": False,
|
|
30
|
-
"useTimestamp": True,
|
|
31
|
-
})
|
|
32
|
-
logger.success("Application started")
|
|
33
|
-
logger.info("Environment: dev")
|
|
34
|
-
logger.w("Warning")
|
|
35
|
-
logger.e("Error")
|
|
36
|
-
logger.d("Debug")
|
|
37
|
-
|
|
38
|
-
logger.configure({"useTimestamp": False})
|
|
39
|
-
logger.info("User:", {"id": 1, "name": "John"})
|
|
40
|
-
logger.error("Failed", Exception("Connection failed"))
|
|
41
|
-
|
|
42
|
-
# Error handler for routers (e.g. FastAPI/Starlette)
|
|
43
|
-
on_error = create_error_handler()
|
|
44
|
-
on_error(exception, request)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Config
|
|
48
|
-
|
|
49
|
-
| Option | Description |
|
|
50
|
-
|----------------|----------------------------------------|
|
|
51
|
-
| `levels` | Enable/disable per level |
|
|
52
|
-
| `useColors` | ANSI colors on/off |
|
|
53
|
-
| `useLevels` | Show level label before message |
|
|
54
|
-
| `useSymbols` | Use symbols (x, !, i, ✓, d) or text |
|
|
55
|
-
| `useTimestamp`| ISO timestamp before message |
|
|
56
|
-
|
|
57
|
-
## Exports
|
|
58
|
-
|
|
59
|
-
- `EzLog` – logger class (create instances yourself)
|
|
60
|
-
- `create_error_handler(is_http_error=..., get_method=..., get_url=...)` – for router error callbacks
|
|
61
|
-
- Types: `LogLevel`, `LogColors`, `EzlogConfig`, `LevelsConfig`, `LevelConfig`, `LogArgs`, `ConsoleMethod`
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
ezlog: simple, performant logging with ANSI colors (Python port of ezlog).
|
|
3
|
-
Install as ezlog-py from PyPI; import as: from ezlog import EzLog, create_error_handler.
|
|
4
|
-
5 levels: error, warn, info, success, debug. Short aliases: e, w, i, s, d.
|
|
5
|
-
"""
|
|
6
|
-
from ezlog.ezlog import EzLog, create_error_handler
|
|
7
|
-
from ezlog.types import (
|
|
8
|
-
ConsoleMethod,
|
|
9
|
-
EzlogConfig,
|
|
10
|
-
LevelConfig,
|
|
11
|
-
LevelsConfig,
|
|
12
|
-
LogArgs,
|
|
13
|
-
LogColors,
|
|
14
|
-
LogLevel,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
__all__ = [
|
|
18
|
-
"EzLog",
|
|
19
|
-
"create_error_handler",
|
|
20
|
-
"LogLevel",
|
|
21
|
-
"LogColors",
|
|
22
|
-
"EzlogConfig",
|
|
23
|
-
"LevelsConfig",
|
|
24
|
-
"LevelConfig",
|
|
25
|
-
"LogArgs",
|
|
26
|
-
"ConsoleMethod",
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def main() -> None:
|
|
31
|
-
"""CLI entry point: short demo (users create their own EzLog())."""
|
|
32
|
-
logger = EzLog(
|
|
33
|
-
{
|
|
34
|
-
"levels": {
|
|
35
|
-
"error": True,
|
|
36
|
-
"warn": True,
|
|
37
|
-
"info": True,
|
|
38
|
-
"success": True,
|
|
39
|
-
"debug": False,
|
|
40
|
-
},
|
|
41
|
-
"useColors": True,
|
|
42
|
-
"useLevels": True,
|
|
43
|
-
"useSymbols": False,
|
|
44
|
-
"useTimestamp": True,
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
logger.success("Application started")
|
|
48
|
-
logger.info("Environment: dev")
|
|
49
|
-
logger.w("Warning message")
|
|
50
|
-
logger.e("Error message")
|
|
51
|
-
logger.d("Debug message")
|
|
52
|
-
logger.info("User data:", {"id": 1, "name": "John"})
|
|
53
|
-
logger.configure({"useTimestamp": False})
|
|
54
|
-
logger.s("Done")
|
|
File without changes
|