dlf4p 1.1.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 ADDED
@@ -0,0 +1,23 @@
1
+ """Dexoron Logging Framework (dlf-py)."""
2
+
3
+ from .logger import (
4
+ setup,
5
+ debug,
6
+ info,
7
+ success,
8
+ warning,
9
+ error,
10
+ fatal,
11
+ )
12
+
13
+ __all__ = [
14
+ "setup",
15
+ "debug",
16
+ "info",
17
+ "success",
18
+ "warning",
19
+ "error",
20
+ "fatal",
21
+ ]
22
+
23
+ __version__ = "1.1.0"
dlf4p/logger.py ADDED
@@ -0,0 +1,73 @@
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
+ 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
+
21
+ def setup(time=True, color=True, simple=False, file_logging=False):
22
+ global useTime, useColor, simpleLog, logFile, LOG_FILENAME
23
+ useTime = time
24
+ useColor = color
25
+ simpleLog = simple
26
+ if file_logging:
27
+ LOG_FILENAME = f"logger-{get_data()}-{get_time()}.log"
28
+ def logFile(msg):
29
+ with open(LOG_FILENAME, "a") as log_handle:
30
+ log_handle.write(msg + "\n")
31
+ else:
32
+ def logFile(msg):
33
+ return None
34
+
35
+ def _print(level, prefix, content, color=None):
36
+ base_msg = ""
37
+
38
+ if useTime:
39
+ base_msg += f"[{get_time()}] "
40
+
41
+ if simpleLog or not prefix:
42
+ base_msg += f"[{level}]"
43
+ else:
44
+ base_msg += f"[{prefix}/{level}]"
45
+
46
+ base_msg += f": {str(content)}"
47
+
48
+ if useColor and color:
49
+ console_msg = f"{color}{base_msg}{reset}"
50
+ else:
51
+ console_msg = base_msg
52
+
53
+ print(console_msg)
54
+ logFile(base_msg)
55
+
56
+
57
+ def debug(content, prefix=None):
58
+ _print("DEBUG", prefix, content)
59
+
60
+ def info(content, prefix=None):
61
+ _print("INFO", prefix, content)
62
+
63
+ def success(content, prefix=None):
64
+ _print("SUCCESS", prefix, content, green)
65
+
66
+ def warning(content, prefix=None):
67
+ _print("WARNING", prefix, content, yellow)
68
+
69
+ def error(content, prefix=None):
70
+ _print("ERROR", prefix, content, red)
71
+
72
+ def fatal(content, prefix=None):
73
+ _print("FATAL", prefix, content, bold_red)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dexoron (Bezotechestvo Vladimir) [main@dexoron.su]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.1
2
+ Name: dlf4p
3
+ Version: 1.1.0
4
+ Summary: Dexoron Logging Framework for Python
5
+ Home-page: https://gitlab.com/dexoron/dlf-py
6
+ Author: Dexoron
7
+ Author-email: main@dexoron.su
8
+ License: UNKNOWN
9
+ Project-URL: Homepage, https://dexoron.su
10
+ Project-URL: Repository, https://gitlab.com/dexoron/dlf-py
11
+ Keywords: logging logger dlf dexoron
12
+ Platform: UNKNOWN
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+
20
+ # dlf4p — Dexoron Logging Framework for Python
21
+
22
+ `dlf4p` is a lightweight and convenient logger for Python inspired by **SLF4J**.
23
+ It provides a simple API for logging messages with support for log levels, colored console output, timestamps, and file logging.
24
+
25
+ The project is being developed as part of the **DLF (Dexoron Logging Framework)** family, with plans for implementations in other programming languages.
26
+
27
+ ---
28
+
29
+ ## Features
30
+
31
+ * Log levels: `DEBUG`, `INFO`, `SUCCESS`, `WARNING`, `ERROR`, `FATAL`
32
+ * Colored console output
33
+ * Timestamp support
34
+ * Prefix support (e.g., module or component name)
35
+ * File logging
36
+ * Simple configuration via `setup()`
37
+ * Lightweight and with no external dependencies
38
+
39
+ ---
40
+
41
+ ## Installation
42
+
43
+ Install from PyPI:
44
+
45
+ ```bash
46
+ pip install dlf4p
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Quick Start
52
+
53
+ ```python
54
+ import dlf4p an dlf
55
+
56
+ dlf.setup(time=True, color=True, simple=False, file_logging=True)
57
+
58
+ dlf.info("Application started", "Main")
59
+ dlf.success("Server successfully started", "Server")
60
+ dlf.warning("Slow response", "API")
61
+ dlf.error("Database connection error", "Database")
62
+ dlf.fatal("Critical error", "System")
63
+ ```
64
+
65
+ Example console output:
66
+
67
+ ```
68
+ [12:30:10] [Main/INFO]: Application started
69
+ [12:30:11] [Server/SUCCESS]: Server successfully started
70
+ [12:30:12] [API/WARNING]: Slow response
71
+ [12:30:13] [Database/ERROR]: Database connection error
72
+ [12:30:14] [System/FATAL]: Critical error
73
+ ```
74
+
75
+ > Logs are saved to a file without ANSI color codes.
76
+
77
+ ---
78
+
79
+ ## Configuration
80
+
81
+ The `setup()` function is used to configure the logger:
82
+
83
+ ```python
84
+ dlf.setup(
85
+ time=True, # show timestamp
86
+ color=True, # enable colored output
87
+ simple=False, # simplified log format (without prefixes)
88
+ file_logging=True # enable file logging
89
+ )
90
+ ```
91
+
92
+ ### Parameters:
93
+
94
+ * `time` — enable or disable timestamps
95
+ * `color` — enable or disable colors
96
+ * `simple` — disable prefixes
97
+ * `file_logging` — enable writing logs to a file
98
+
99
+ ---
100
+
101
+ ## Philosophy
102
+
103
+ `dlf4p` is inspired by **SLF4J (Simple Logging Facade for Java)** and aims to:
104
+
105
+ * provide a simple and unified logging interface
106
+ * remain minimalistic
107
+ * have no external dependencies
108
+ * be easily extensible to other programming languages
109
+
110
+ ---
111
+
112
+ ## License
113
+
114
+ This project is licensed under the MIT License. See the `LICENSE` file for details.
115
+
116
+ ---
117
+
118
+ ## Author
119
+
120
+ **Dexoron**
121
+
122
+ GitLab: [https://gitlab.com/dexoron](https://gitlab.com/dexoron)
123
+ GitHub: [https://github.com/dexoron](https://github.com/dexoron)
124
+ Website: [https://dexoron.su](https://dexoron.su)
125
+
126
+ ---
127
+
128
+ > dlf4p — a simple logger today, a full logging framework tomorrow.
129
+
@@ -0,0 +1,7 @@
1
+ dlf4p/__init__.py,sha256=JL2q1W0LbWP4p2oq8MwabPfoVRHei-qS9hDKgsWVq4M,279
2
+ dlf4p/logger.py,sha256=pAKjruizJiFb76w2nrDGteSNhJb7E_yZw7GqXPt56ug,1732
3
+ dlf4p-1.1.0.dist-info/LICENSE,sha256=oLue9bkNUZzdzvNbFJBY_2VoUU1WymJIL3WcQDwkOdw,1107
4
+ dlf4p-1.1.0.dist-info/METADATA,sha256=hd9ics3l0otVW3eBNPi8zhoImoFwvG830zzazttA5j4,3165
5
+ dlf4p-1.1.0.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
6
+ dlf4p-1.1.0.dist-info/top_level.txt,sha256=eKKdvmTDaFeM6QvC1FxHhXdRpthceJ2zqPnvk2rMRfg,6
7
+ dlf4p-1.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.46.3)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ dlf4p