dlf4p 1.1.1__py3-none-any.whl → 1.2.0__py3-none-any.whl
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.
- dlf4p/__init__.py +3 -1
- dlf4p/logger.py +59 -26
- dlf4p/utils.py +21 -0
- {dlf4p-1.1.1.dist-info → dlf4p-1.2.0.dist-info}/METADATA +51 -3
- dlf4p-1.2.0.dist-info/RECORD +10 -0
- {dlf4p-1.1.1.dist-info → dlf4p-1.2.0.dist-info}/top_level.txt +1 -0
- test/__init__.py +0 -0
- test/main.py +19 -0
- dlf4p-1.1.1.dist-info/RECORD +0 -7
- {dlf4p-1.1.1.dist-info → dlf4p-1.2.0.dist-info}/LICENSE +0 -0
- {dlf4p-1.1.1.dist-info → dlf4p-1.2.0.dist-info}/WHEEL +0 -0
dlf4p/__init__.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Dexoron Logging Framework (dlf-py)."""
|
|
2
2
|
|
|
3
3
|
from .logger import (
|
|
4
|
+
Logger,
|
|
4
5
|
setup,
|
|
5
6
|
debug,
|
|
6
7
|
info,
|
|
@@ -11,6 +12,7 @@ from .logger import (
|
|
|
11
12
|
)
|
|
12
13
|
|
|
13
14
|
__all__ = [
|
|
15
|
+
"Logger",
|
|
14
16
|
"setup",
|
|
15
17
|
"debug",
|
|
16
18
|
"info",
|
|
@@ -20,4 +22,4 @@ __all__ = [
|
|
|
20
22
|
"fatal",
|
|
21
23
|
]
|
|
22
24
|
|
|
23
|
-
__version__ = "1.
|
|
25
|
+
__version__ = "1.2.0"
|
dlf4p/logger.py
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
from
|
|
1
|
+
from .utils import (
|
|
2
|
+
red,
|
|
3
|
+
green,
|
|
4
|
+
yellow,
|
|
5
|
+
reset,
|
|
6
|
+
bold_red,
|
|
7
|
+
useTime,
|
|
8
|
+
useColor,
|
|
9
|
+
simpleLog,
|
|
10
|
+
logFile,
|
|
11
|
+
get_time,
|
|
12
|
+
get_data,
|
|
13
|
+
levels,
|
|
14
|
+
logLevel,
|
|
15
|
+
)
|
|
2
16
|
|
|
3
|
-
red = "\033[31m"
|
|
4
|
-
green = "\033[32m"
|
|
5
|
-
yellow = "\033[33m"
|
|
6
|
-
reset = "\033[0m"
|
|
7
|
-
bold_red = "\033[1;31m"
|
|
8
|
-
|
|
9
|
-
useTime = True
|
|
10
|
-
useColor = True
|
|
11
|
-
simpleLog = False
|
|
12
17
|
LOG_FILENAME = None
|
|
13
|
-
def logFile(msg):
|
|
14
|
-
return None
|
|
15
|
-
|
|
16
|
-
def get_time():
|
|
17
|
-
return datetime.now().strftime("%H:%M:%S")
|
|
18
|
-
def get_data():
|
|
19
|
-
return datetime.now().strftime("%d.%m.%Y")
|
|
20
18
|
|
|
21
|
-
def setup(time=True, color=True, simple=False, file_logging=
|
|
19
|
+
def setup(time: bool=True, color: bool=True, simple: bool=False, file_logging: bool=True):
|
|
22
20
|
global useTime, useColor, simpleLog, logFile, LOG_FILENAME
|
|
23
21
|
useTime = time
|
|
24
22
|
useColor = color
|
|
@@ -32,7 +30,7 @@ def setup(time=True, color=True, simple=False, file_logging=False):
|
|
|
32
30
|
def logFile(msg):
|
|
33
31
|
return None
|
|
34
32
|
|
|
35
|
-
def _print(level, prefix, content, color=None):
|
|
33
|
+
def _print(level: int, prefix: str, content: str, color: str=None):
|
|
36
34
|
base_msg = ""
|
|
37
35
|
|
|
38
36
|
if useTime:
|
|
@@ -53,21 +51,56 @@ def _print(level, prefix, content, color=None):
|
|
|
53
51
|
print(console_msg)
|
|
54
52
|
logFile(base_msg)
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
def
|
|
54
|
+
class Logger:
|
|
55
|
+
def __init__(self, prefix: str=None):
|
|
56
|
+
self.prefix = prefix
|
|
57
|
+
|
|
58
|
+
def getLogger(self, prefix: str):
|
|
59
|
+
return Logger(prefix)
|
|
60
|
+
|
|
61
|
+
def setLevel(self, level: int):
|
|
62
|
+
global logLevel
|
|
63
|
+
logLevel = level
|
|
64
|
+
_print("INFO", self.prefix, f"Log level set to {levels[level]}")
|
|
65
|
+
|
|
66
|
+
def debug(self, content: str):
|
|
67
|
+
if logLevel <= 0:
|
|
68
|
+
_print("DEBUG", self.prefix, content)
|
|
69
|
+
|
|
70
|
+
def info(self, content: str):
|
|
71
|
+
if logLevel <= 1:
|
|
72
|
+
_print("INFO", self.prefix, content)
|
|
73
|
+
|
|
74
|
+
def success(self, content: str):
|
|
75
|
+
if logLevel <= 2:
|
|
76
|
+
_print("SUCCESS", self.prefix, content, green)
|
|
77
|
+
|
|
78
|
+
def warning(self, content: str):
|
|
79
|
+
if logLevel <= 3:
|
|
80
|
+
_print("WARNING", self.prefix, content, yellow)
|
|
81
|
+
|
|
82
|
+
def error(self, content: str):
|
|
83
|
+
if logLevel <= 4:
|
|
84
|
+
_print("ERROR", self.prefix, content, red)
|
|
85
|
+
|
|
86
|
+
def fatal(self, content: str):
|
|
87
|
+
if logLevel <= 5:
|
|
88
|
+
_print("FATAL", self.prefix, content, bold_red)
|
|
89
|
+
|
|
90
|
+
def debug(content: str, prefix: str=None):
|
|
58
91
|
_print("DEBUG", prefix, content)
|
|
59
92
|
|
|
60
|
-
def info(content, prefix=None):
|
|
93
|
+
def info(content: str, prefix: str=None):
|
|
61
94
|
_print("INFO", prefix, content)
|
|
62
95
|
|
|
63
|
-
def success(content, prefix=None):
|
|
96
|
+
def success(content: str, prefix: str=None):
|
|
64
97
|
_print("SUCCESS", prefix, content, green)
|
|
65
98
|
|
|
66
|
-
def warning(content, prefix=None):
|
|
99
|
+
def warning(content: str, prefix: str=None):
|
|
67
100
|
_print("WARNING", prefix, content, yellow)
|
|
68
101
|
|
|
69
|
-
def error(content, prefix=None):
|
|
102
|
+
def error(content: str, prefix: str=None):
|
|
70
103
|
_print("ERROR", prefix, content, red)
|
|
71
104
|
|
|
72
|
-
def fatal(content, prefix=None):
|
|
105
|
+
def fatal(content: str, prefix: str=None):
|
|
73
106
|
_print("FATAL", prefix, content, bold_red)
|
dlf4p/utils.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
red = "\033[31m"
|
|
4
|
+
green = "\033[32m"
|
|
5
|
+
yellow = "\033[33m"
|
|
6
|
+
reset = "\033[0m"
|
|
7
|
+
bold_red = "\033[1;31m"
|
|
8
|
+
|
|
9
|
+
useTime = True
|
|
10
|
+
useColor = True
|
|
11
|
+
simpleLog = False
|
|
12
|
+
def logFile(msg):
|
|
13
|
+
return None
|
|
14
|
+
|
|
15
|
+
def get_time():
|
|
16
|
+
return datetime.now().strftime("%H:%M:%S")
|
|
17
|
+
def get_data():
|
|
18
|
+
return datetime.now().strftime("%d.%m.%Y")
|
|
19
|
+
|
|
20
|
+
levels = ["DEBUG", "INFO", "SUCCESS", "WARNING", "ERROR", "FATAL"]
|
|
21
|
+
logLevel = 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dlf4p
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Dexoron Logging Framework for Python
|
|
5
5
|
Home-page: https://gitlab.com/dexoron/dlf4p
|
|
6
6
|
Author: Dexoron
|
|
@@ -24,6 +24,9 @@ It provides a simple API for logging messages with support for log levels, color
|
|
|
24
24
|
|
|
25
25
|
The project is being developed as part of the **DLF (Dexoron Logging Framework)** family, with plans for implementations in other programming languages.
|
|
26
26
|
|
|
27
|
+
GitLab repository: https://gitlab.com/dexoron/dlf4p
|
|
28
|
+
PyPi project: https://pypi.org/project/dlf4p
|
|
29
|
+
|
|
27
30
|
---
|
|
28
31
|
|
|
29
32
|
## Features
|
|
@@ -62,9 +65,9 @@ dlf.error("Database connection error", "Database")
|
|
|
62
65
|
dlf.fatal("Critical error", "System")
|
|
63
66
|
```
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
Console output:
|
|
66
69
|
|
|
67
|
-
```
|
|
70
|
+
```log
|
|
68
71
|
[12:30:10] [Main/INFO]: Application started
|
|
69
72
|
[12:30:11] [Server/SUCCESS]: Server successfully started
|
|
70
73
|
[12:30:12] [API/WARNING]: Slow response
|
|
@@ -72,6 +75,31 @@ Example console output:
|
|
|
72
75
|
[12:30:14] [System/FATAL]: Critical error
|
|
73
76
|
```
|
|
74
77
|
|
|
78
|
+
Logger class example:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import dlf4p as dlf
|
|
82
|
+
|
|
83
|
+
dlf.setup(time=True, color=True, simple=False, file_logging=True)
|
|
84
|
+
|
|
85
|
+
log = dlf.Logger("Main")
|
|
86
|
+
log.info("Application started")
|
|
87
|
+
|
|
88
|
+
log = dlf.Logger("Core")
|
|
89
|
+
log.setLevel(2) # SUCCESS and higher
|
|
90
|
+
log.info("Core module initialized")
|
|
91
|
+
log.success("Submodule loaded successfully")
|
|
92
|
+
log.warning("Disabled System modules")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Console output:
|
|
96
|
+
|
|
97
|
+
```log
|
|
98
|
+
[12:30:10] [Main/INFO]: Application started
|
|
99
|
+
[12:30:11] [Core/SUCCESS]: Submodule loaded successfully
|
|
100
|
+
[12:30:12] [Core/WARNING]: Disabled System modules
|
|
101
|
+
```
|
|
102
|
+
|
|
75
103
|
> Logs are saved to a file without ANSI color codes.
|
|
76
104
|
|
|
77
105
|
---
|
|
@@ -98,6 +126,16 @@ dlf.setup(
|
|
|
98
126
|
|
|
99
127
|
---
|
|
100
128
|
|
|
129
|
+
## Run Example
|
|
130
|
+
|
|
131
|
+
From the project root:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
python3 -m test.main
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
101
139
|
## Philosophy
|
|
102
140
|
|
|
103
141
|
`dlf4p` is inspired by **SLF4J (Simple Logging Facade for Java)** and aims to:
|
|
@@ -125,5 +163,15 @@ Website: [https://dexoron.su](https://dexoron.su)
|
|
|
125
163
|
|
|
126
164
|
---
|
|
127
165
|
|
|
166
|
+
## Project Links
|
|
167
|
+
|
|
168
|
+
Changelog: `CHANGELOG`
|
|
169
|
+
Contributing guide: `CONTRIBUTING.md`
|
|
170
|
+
GitLab repository: https://gitlab.com/dexoron/dlf4p
|
|
171
|
+
PyPi project: https://pypi.org/project/dlf4p
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
128
175
|
> dlf4p — a simple logger today, a full logging framework tomorrow.
|
|
129
176
|
|
|
177
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
dlf4p/__init__.py,sha256=2_DMtLbVmbvtKjlGduS1fupQ720Tvrkxpz4C0MWq_IM,305
|
|
2
|
+
dlf4p/logger.py,sha256=qRbEH_pkem189uXzToMwUEnevdOQREocHHQZzPLnPt8,2718
|
|
3
|
+
dlf4p/utils.py,sha256=7FuSbrqBKtDxSeAlywyhSImx1e-8tRPatH1wzeel3eE,420
|
|
4
|
+
test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
test/main.py,sha256=EYKAgw5jEF72VpnT3YgJLMBJVNmRZZJZjBlsIdQIxCg,487
|
|
6
|
+
dlf4p-1.2.0.dist-info/LICENSE,sha256=oLue9bkNUZzdzvNbFJBY_2VoUU1WymJIL3WcQDwkOdw,1107
|
|
7
|
+
dlf4p-1.2.0.dist-info/METADATA,sha256=xNhLncGHZnO8P49krw2mWIyh2KaDAuiABbN4LTExyQg,4068
|
|
8
|
+
dlf4p-1.2.0.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
|
|
9
|
+
dlf4p-1.2.0.dist-info/top_level.txt,sha256=0Ldhm7IayO_GZtFUzdeIabZXnnoBgyMcRL3wusZw7hY,11
|
|
10
|
+
dlf4p-1.2.0.dist-info/RECORD,,
|
test/__init__.py
ADDED
|
File without changes
|
test/main.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import dlf4p
|
|
2
|
+
|
|
3
|
+
dlf4p.setup(time=True, color=True, simple=False, file_logging=True)
|
|
4
|
+
|
|
5
|
+
dlf = dlf4p.Logger("Main")
|
|
6
|
+
|
|
7
|
+
dlf.info("Test info message")
|
|
8
|
+
dlf.success("Test success message")
|
|
9
|
+
dlf.warning("Test warning message")
|
|
10
|
+
dlf.error("Test error message")
|
|
11
|
+
dlf.debug("Test debug message")
|
|
12
|
+
|
|
13
|
+
dlf = dlf4p.Logger("Core")
|
|
14
|
+
dlf.setLevel(2)
|
|
15
|
+
dlf.info("Test info message")
|
|
16
|
+
dlf.success("Test success message")
|
|
17
|
+
dlf.warning("Test warning message")
|
|
18
|
+
dlf.error("Test error message")
|
|
19
|
+
dlf.debug("Test debug message")
|
dlf4p-1.1.1.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
dlf4p/__init__.py,sha256=JL2q1W0LbWP4p2oq8MwabPfoVRHei-qS9hDKgsWVq4M,279
|
|
2
|
-
dlf4p/logger.py,sha256=pAKjruizJiFb76w2nrDGteSNhJb7E_yZw7GqXPt56ug,1732
|
|
3
|
-
dlf4p-1.1.1.dist-info/LICENSE,sha256=oLue9bkNUZzdzvNbFJBY_2VoUU1WymJIL3WcQDwkOdw,1107
|
|
4
|
-
dlf4p-1.1.1.dist-info/METADATA,sha256=KXR3i-dfvVpnpNsTcgzWRgnhgmmQB6E-T8-eMhhNQpA,3163
|
|
5
|
-
dlf4p-1.1.1.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
|
|
6
|
-
dlf4p-1.1.1.dist-info/top_level.txt,sha256=eKKdvmTDaFeM6QvC1FxHhXdRpthceJ2zqPnvk2rMRfg,6
|
|
7
|
-
dlf4p-1.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|