pythonLogs 4.0.2__tar.gz → 4.0.3__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.
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/PKG-INFO +49 -45
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/README.md +48 -44
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pyproject.toml +7 -16
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/LICENSE +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/.env.example +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/__init__.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/basic_log.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/constants.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/factory.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/log_utils.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/memory_utils.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/settings.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/size_rotating.py +0 -0
- {pythonlogs-4.0.2 → pythonlogs-4.0.3}/pythonLogs/timed_rotating.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pythonLogs
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.3
|
|
4
4
|
Summary: High-performance Python logging library with file rotation and optimized caching for better performance
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: python3,python-3,python,log,logging,logger,logutils,log-utils,pythonLogs
|
|
@@ -54,11 +54,15 @@ High-performance Python logging library with file rotation and optimized caching
|
|
|
54
54
|
- [Timed Rotating Logger](#timed-rotating-logger)
|
|
55
55
|
- [Context Manager Support](#context-manager-support)
|
|
56
56
|
- [Advanced Factory Features](#advanced-factory-features)
|
|
57
|
+
- [Environment Variables](#env-variables-optional--production)
|
|
57
58
|
- [Memory Management](#memory-management)
|
|
59
|
+
- [Flexible Configuration Options](#flexible-configuration-options)
|
|
58
60
|
- [Migration Guide](#migration-guide)
|
|
59
61
|
- [Performance Improvements](#performance-improvements)
|
|
60
|
-
- [Environment Variables](#env-variables-optional)
|
|
61
62
|
- [Development](#source-code)
|
|
63
|
+
- [Run Tests and Get Coverage Report using Poe](#run-tests-and-get-coverage-report-using-poe)
|
|
64
|
+
- [License](#license)
|
|
65
|
+
- [Buy me a cup of coffee](#buy-me-a-cup-of-coffee)
|
|
62
66
|
|
|
63
67
|
|
|
64
68
|
|
|
@@ -264,6 +268,7 @@ logger.warning("This is a warning example")
|
|
|
264
268
|
|
|
265
269
|
# Context Manager Support
|
|
266
270
|
|
|
271
|
+
Slow, but if you want immediate, deterministic cleanup for a specific scope.\
|
|
267
272
|
All logger types support context managers for automatic resource cleanup and exception safety:
|
|
268
273
|
|
|
269
274
|
## Basic Usage
|
|
@@ -333,44 +338,6 @@ assert logger1 is logger2
|
|
|
333
338
|
clear_logger_registry()
|
|
334
339
|
```
|
|
335
340
|
|
|
336
|
-
## Flexible Configuration Options
|
|
337
|
-
You can use either enums (for type safety) or strings (for simplicity):
|
|
338
|
-
|
|
339
|
-
```python
|
|
340
|
-
from pythonLogs import LogLevel, RotateWhen, LoggerType
|
|
341
|
-
|
|
342
|
-
# Option 1: Type-safe enums (recommended)
|
|
343
|
-
LogLevel.DEBUG # "DEBUG"
|
|
344
|
-
LogLevel.INFO # "INFO"
|
|
345
|
-
LogLevel.WARNING # "WARNING"
|
|
346
|
-
LogLevel.ERROR # "ERROR"
|
|
347
|
-
LogLevel.CRITICAL # "CRITICAL"
|
|
348
|
-
|
|
349
|
-
# Option 2: String values (case-insensitive)
|
|
350
|
-
"debug" # Same as LogLevel.DEBUG
|
|
351
|
-
"info" # Same as LogLevel.INFO
|
|
352
|
-
"warning" # Same as LogLevel.WARNING
|
|
353
|
-
"warn" # Same as LogLevel.WARN (alias)
|
|
354
|
-
"error" # Same as LogLevel.ERROR
|
|
355
|
-
"critical" # Same as LogLevel.CRITICAL
|
|
356
|
-
"crit" # Same as LogLevel.CRIT (alias)
|
|
357
|
-
# Also supports: "DEBUG", "Info", "Warning", etc.
|
|
358
|
-
|
|
359
|
-
# RotateWhen values
|
|
360
|
-
RotateWhen.MIDNIGHT # "midnight"
|
|
361
|
-
RotateWhen.HOURLY # "H"
|
|
362
|
-
RotateWhen.DAILY # "D"
|
|
363
|
-
RotateWhen.MONDAY # "W0"
|
|
364
|
-
# ... through SUNDAY # "W6"
|
|
365
|
-
# String equivalents: "midnight", "H", "D", "W0"-"W6"
|
|
366
|
-
|
|
367
|
-
# LoggerType values
|
|
368
|
-
LoggerType.BASIC # "basic"
|
|
369
|
-
LoggerType.SIZE_ROTATING # "size_rotating"
|
|
370
|
-
LoggerType.TIMED_ROTATING # "timed_rotating"
|
|
371
|
-
# String equivalents: "basic", "size_rotating", "timed_rotating"
|
|
372
|
-
```
|
|
373
|
-
|
|
374
341
|
## Production Setup Example
|
|
375
342
|
```python
|
|
376
343
|
from pythonLogs import size_rotating_logger, timed_rotating_logger, LogLevel, RotateWhen
|
|
@@ -415,9 +382,9 @@ audit_logger.info("User admin logged in")
|
|
|
415
382
|
```
|
|
416
383
|
|
|
417
384
|
## Env Variables (Optional | Production)
|
|
418
|
-
.env variables can be used by leaving all options blank when calling the function
|
|
419
|
-
If not specified inside the .env file, it will use the dafault value
|
|
420
|
-
This is a good approach for production environments, since options can be changed easily
|
|
385
|
+
The .env variables file can be used by leaving all options blank when calling the function.\
|
|
386
|
+
If not specified inside the .env file, it will use the dafault value.\
|
|
387
|
+
This is a good approach for production environments, since options can be changed easily.
|
|
421
388
|
```python
|
|
422
389
|
from pythonLogs import timed_rotating_logger
|
|
423
390
|
log = timed_rotating_logger()
|
|
@@ -447,8 +414,6 @@ LOG_ROTATE_FILE_SUFIX="%Y%m%d"
|
|
|
447
414
|
```
|
|
448
415
|
|
|
449
416
|
|
|
450
|
-
|
|
451
|
-
|
|
452
417
|
# Memory Management
|
|
453
418
|
|
|
454
419
|
The library includes comprehensive memory management features to prevent memory leaks and optimize resource usage:
|
|
@@ -545,6 +510,45 @@ clear_logger_registry()
|
|
|
545
510
|
```
|
|
546
511
|
|
|
547
512
|
|
|
513
|
+
# Flexible Configuration Options
|
|
514
|
+
You can use either enums (for type safety) or strings (for simplicity):
|
|
515
|
+
|
|
516
|
+
```python
|
|
517
|
+
from pythonLogs import LogLevel, RotateWhen, LoggerType
|
|
518
|
+
|
|
519
|
+
# Option 1: Type-safe enums (recommended)
|
|
520
|
+
LogLevel.DEBUG # "DEBUG"
|
|
521
|
+
LogLevel.INFO # "INFO"
|
|
522
|
+
LogLevel.WARNING # "WARNING"
|
|
523
|
+
LogLevel.ERROR # "ERROR"
|
|
524
|
+
LogLevel.CRITICAL # "CRITICAL"
|
|
525
|
+
|
|
526
|
+
# Option 2: String values (case-insensitive)
|
|
527
|
+
"debug" # Same as LogLevel.DEBUG
|
|
528
|
+
"info" # Same as LogLevel.INFO
|
|
529
|
+
"warning" # Same as LogLevel.WARNING
|
|
530
|
+
"warn" # Same as LogLevel.WARN (alias)
|
|
531
|
+
"error" # Same as LogLevel.ERROR
|
|
532
|
+
"critical" # Same as LogLevel.CRITICAL
|
|
533
|
+
"crit" # Same as LogLevel.CRIT (alias)
|
|
534
|
+
# Also supports: "DEBUG", "Info", "Warning", etc.
|
|
535
|
+
|
|
536
|
+
# RotateWhen values
|
|
537
|
+
RotateWhen.MIDNIGHT # "midnight"
|
|
538
|
+
RotateWhen.HOURLY # "H"
|
|
539
|
+
RotateWhen.DAILY # "D"
|
|
540
|
+
RotateWhen.MONDAY # "W0"
|
|
541
|
+
# ... through SUNDAY # "W6"
|
|
542
|
+
# String equivalents: "midnight", "H", "D", "W0"-"W6"
|
|
543
|
+
|
|
544
|
+
# LoggerType values
|
|
545
|
+
LoggerType.BASIC # "basic"
|
|
546
|
+
LoggerType.SIZE_ROTATING # "size_rotating"
|
|
547
|
+
LoggerType.TIMED_ROTATING # "timed_rotating"
|
|
548
|
+
# String equivalents: "basic", "size_rotating", "timed_rotating"
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
|
|
548
552
|
# Migration Guide
|
|
549
553
|
|
|
550
554
|
## Upgrading from Legacy to Factory Pattern
|
|
@@ -24,11 +24,15 @@ High-performance Python logging library with file rotation and optimized caching
|
|
|
24
24
|
- [Timed Rotating Logger](#timed-rotating-logger)
|
|
25
25
|
- [Context Manager Support](#context-manager-support)
|
|
26
26
|
- [Advanced Factory Features](#advanced-factory-features)
|
|
27
|
+
- [Environment Variables](#env-variables-optional--production)
|
|
27
28
|
- [Memory Management](#memory-management)
|
|
29
|
+
- [Flexible Configuration Options](#flexible-configuration-options)
|
|
28
30
|
- [Migration Guide](#migration-guide)
|
|
29
31
|
- [Performance Improvements](#performance-improvements)
|
|
30
|
-
- [Environment Variables](#env-variables-optional)
|
|
31
32
|
- [Development](#source-code)
|
|
33
|
+
- [Run Tests and Get Coverage Report using Poe](#run-tests-and-get-coverage-report-using-poe)
|
|
34
|
+
- [License](#license)
|
|
35
|
+
- [Buy me a cup of coffee](#buy-me-a-cup-of-coffee)
|
|
32
36
|
|
|
33
37
|
|
|
34
38
|
|
|
@@ -234,6 +238,7 @@ logger.warning("This is a warning example")
|
|
|
234
238
|
|
|
235
239
|
# Context Manager Support
|
|
236
240
|
|
|
241
|
+
Slow, but if you want immediate, deterministic cleanup for a specific scope.\
|
|
237
242
|
All logger types support context managers for automatic resource cleanup and exception safety:
|
|
238
243
|
|
|
239
244
|
## Basic Usage
|
|
@@ -303,44 +308,6 @@ assert logger1 is logger2
|
|
|
303
308
|
clear_logger_registry()
|
|
304
309
|
```
|
|
305
310
|
|
|
306
|
-
## Flexible Configuration Options
|
|
307
|
-
You can use either enums (for type safety) or strings (for simplicity):
|
|
308
|
-
|
|
309
|
-
```python
|
|
310
|
-
from pythonLogs import LogLevel, RotateWhen, LoggerType
|
|
311
|
-
|
|
312
|
-
# Option 1: Type-safe enums (recommended)
|
|
313
|
-
LogLevel.DEBUG # "DEBUG"
|
|
314
|
-
LogLevel.INFO # "INFO"
|
|
315
|
-
LogLevel.WARNING # "WARNING"
|
|
316
|
-
LogLevel.ERROR # "ERROR"
|
|
317
|
-
LogLevel.CRITICAL # "CRITICAL"
|
|
318
|
-
|
|
319
|
-
# Option 2: String values (case-insensitive)
|
|
320
|
-
"debug" # Same as LogLevel.DEBUG
|
|
321
|
-
"info" # Same as LogLevel.INFO
|
|
322
|
-
"warning" # Same as LogLevel.WARNING
|
|
323
|
-
"warn" # Same as LogLevel.WARN (alias)
|
|
324
|
-
"error" # Same as LogLevel.ERROR
|
|
325
|
-
"critical" # Same as LogLevel.CRITICAL
|
|
326
|
-
"crit" # Same as LogLevel.CRIT (alias)
|
|
327
|
-
# Also supports: "DEBUG", "Info", "Warning", etc.
|
|
328
|
-
|
|
329
|
-
# RotateWhen values
|
|
330
|
-
RotateWhen.MIDNIGHT # "midnight"
|
|
331
|
-
RotateWhen.HOURLY # "H"
|
|
332
|
-
RotateWhen.DAILY # "D"
|
|
333
|
-
RotateWhen.MONDAY # "W0"
|
|
334
|
-
# ... through SUNDAY # "W6"
|
|
335
|
-
# String equivalents: "midnight", "H", "D", "W0"-"W6"
|
|
336
|
-
|
|
337
|
-
# LoggerType values
|
|
338
|
-
LoggerType.BASIC # "basic"
|
|
339
|
-
LoggerType.SIZE_ROTATING # "size_rotating"
|
|
340
|
-
LoggerType.TIMED_ROTATING # "timed_rotating"
|
|
341
|
-
# String equivalents: "basic", "size_rotating", "timed_rotating"
|
|
342
|
-
```
|
|
343
|
-
|
|
344
311
|
## Production Setup Example
|
|
345
312
|
```python
|
|
346
313
|
from pythonLogs import size_rotating_logger, timed_rotating_logger, LogLevel, RotateWhen
|
|
@@ -385,9 +352,9 @@ audit_logger.info("User admin logged in")
|
|
|
385
352
|
```
|
|
386
353
|
|
|
387
354
|
## Env Variables (Optional | Production)
|
|
388
|
-
.env variables can be used by leaving all options blank when calling the function
|
|
389
|
-
If not specified inside the .env file, it will use the dafault value
|
|
390
|
-
This is a good approach for production environments, since options can be changed easily
|
|
355
|
+
The .env variables file can be used by leaving all options blank when calling the function.\
|
|
356
|
+
If not specified inside the .env file, it will use the dafault value.\
|
|
357
|
+
This is a good approach for production environments, since options can be changed easily.
|
|
391
358
|
```python
|
|
392
359
|
from pythonLogs import timed_rotating_logger
|
|
393
360
|
log = timed_rotating_logger()
|
|
@@ -417,8 +384,6 @@ LOG_ROTATE_FILE_SUFIX="%Y%m%d"
|
|
|
417
384
|
```
|
|
418
385
|
|
|
419
386
|
|
|
420
|
-
|
|
421
|
-
|
|
422
387
|
# Memory Management
|
|
423
388
|
|
|
424
389
|
The library includes comprehensive memory management features to prevent memory leaks and optimize resource usage:
|
|
@@ -515,6 +480,45 @@ clear_logger_registry()
|
|
|
515
480
|
```
|
|
516
481
|
|
|
517
482
|
|
|
483
|
+
# Flexible Configuration Options
|
|
484
|
+
You can use either enums (for type safety) or strings (for simplicity):
|
|
485
|
+
|
|
486
|
+
```python
|
|
487
|
+
from pythonLogs import LogLevel, RotateWhen, LoggerType
|
|
488
|
+
|
|
489
|
+
# Option 1: Type-safe enums (recommended)
|
|
490
|
+
LogLevel.DEBUG # "DEBUG"
|
|
491
|
+
LogLevel.INFO # "INFO"
|
|
492
|
+
LogLevel.WARNING # "WARNING"
|
|
493
|
+
LogLevel.ERROR # "ERROR"
|
|
494
|
+
LogLevel.CRITICAL # "CRITICAL"
|
|
495
|
+
|
|
496
|
+
# Option 2: String values (case-insensitive)
|
|
497
|
+
"debug" # Same as LogLevel.DEBUG
|
|
498
|
+
"info" # Same as LogLevel.INFO
|
|
499
|
+
"warning" # Same as LogLevel.WARNING
|
|
500
|
+
"warn" # Same as LogLevel.WARN (alias)
|
|
501
|
+
"error" # Same as LogLevel.ERROR
|
|
502
|
+
"critical" # Same as LogLevel.CRITICAL
|
|
503
|
+
"crit" # Same as LogLevel.CRIT (alias)
|
|
504
|
+
# Also supports: "DEBUG", "Info", "Warning", etc.
|
|
505
|
+
|
|
506
|
+
# RotateWhen values
|
|
507
|
+
RotateWhen.MIDNIGHT # "midnight"
|
|
508
|
+
RotateWhen.HOURLY # "H"
|
|
509
|
+
RotateWhen.DAILY # "D"
|
|
510
|
+
RotateWhen.MONDAY # "W0"
|
|
511
|
+
# ... through SUNDAY # "W6"
|
|
512
|
+
# String equivalents: "midnight", "H", "D", "W0"-"W6"
|
|
513
|
+
|
|
514
|
+
# LoggerType values
|
|
515
|
+
LoggerType.BASIC # "basic"
|
|
516
|
+
LoggerType.SIZE_ROTATING # "size_rotating"
|
|
517
|
+
LoggerType.TIMED_ROTATING # "timed_rotating"
|
|
518
|
+
# String equivalents: "basic", "size_rotating", "timed_rotating"
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
|
|
518
522
|
# Migration Guide
|
|
519
523
|
|
|
520
524
|
## Upgrading from Legacy to Factory Pattern
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
3
3
|
build-backend = "poetry.core.masonry.api"
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
[tool.poetry]
|
|
7
6
|
name = "pythonLogs"
|
|
8
|
-
version = "4.0.
|
|
7
|
+
version = "4.0.3"
|
|
9
8
|
description = "High-performance Python logging library with file rotation and optimized caching for better performance"
|
|
10
9
|
license = "MIT"
|
|
11
10
|
readme = "README.md"
|
|
@@ -31,51 +30,43 @@ classifiers = [
|
|
|
31
30
|
"Natural Language :: English",
|
|
32
31
|
]
|
|
33
32
|
|
|
34
|
-
|
|
35
33
|
[tool.poetry.dependencies]
|
|
36
34
|
python = "^3.10"
|
|
37
35
|
pydantic = "^2.11.7"
|
|
38
36
|
pydantic-settings = "^2.10.1"
|
|
39
37
|
python-dotenv = "^1.1.1"
|
|
40
38
|
|
|
41
|
-
|
|
42
39
|
[tool.poetry.group.test.dependencies]
|
|
43
40
|
coverage = "^7.9.2"
|
|
44
41
|
poethepoet = "^0.36.0"
|
|
45
42
|
psutil = "^7.0.0"
|
|
46
43
|
pytest = "^8.4.1"
|
|
47
44
|
|
|
45
|
+
[tool.poe.tasks]
|
|
46
|
+
_test = "coverage run -m pytest -v"
|
|
47
|
+
_coverage_report = "coverage report"
|
|
48
|
+
_coverage_xml = "coverage xml"
|
|
49
|
+
tests = ["_test", "_coverage_report", "_coverage_xml"]
|
|
50
|
+
test = ["tests"]
|
|
48
51
|
|
|
49
52
|
[tool.poetry.group.test]
|
|
50
53
|
optional = true
|
|
51
54
|
|
|
52
|
-
|
|
53
55
|
[tool.black]
|
|
54
56
|
line-length = 120
|
|
55
57
|
skip-string-normalization = true
|
|
56
58
|
|
|
57
|
-
|
|
58
59
|
[tool.pytest.ini_options]
|
|
59
60
|
markers = [
|
|
60
61
|
"slow: marks tests as slow (deselect with '-m \"not slow\"')"
|
|
61
62
|
]
|
|
62
63
|
|
|
63
|
-
|
|
64
64
|
[tool.coverage.run]
|
|
65
65
|
omit = [
|
|
66
66
|
"tests/*",
|
|
67
67
|
]
|
|
68
68
|
|
|
69
|
-
|
|
70
69
|
[tool.coverage.report]
|
|
71
70
|
exclude_lines = [
|
|
72
71
|
"pragma: no cover",
|
|
73
72
|
]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
[tool.poe.tasks]
|
|
77
|
-
_test = "coverage run -m pytest -v"
|
|
78
|
-
_coverage_report = "coverage report"
|
|
79
|
-
_coverage_xml = "coverage xml"
|
|
80
|
-
tests = ["_test", "_coverage_report", "_coverage_xml"]
|
|
81
|
-
test = ["tests"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|