dlf4p 1.1.0__tar.gz → 1.2.0__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.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dlf4p
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Dexoron Logging Framework for Python
5
- Home-page: https://gitlab.com/dexoron/dlf-py
5
+ Home-page: https://gitlab.com/dexoron/dlf4p
6
6
  Author: Dexoron
7
7
  Author-email: main@dexoron.su
8
8
  License: UNKNOWN
9
9
  Project-URL: Homepage, https://dexoron.su
10
- Project-URL: Repository, https://gitlab.com/dexoron/dlf-py
10
+ Project-URL: Repository, https://gitlab.com/dexoron/dlf4p
11
11
  Keywords: logging logger dlf dexoron
12
12
  Platform: UNKNOWN
13
13
  Classifier: Programming Language :: Python :: 3.10
@@ -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
@@ -51,7 +54,7 @@ pip install dlf4p
51
54
  ## Quick Start
52
55
 
53
56
  ```python
54
- import dlf4p an dlf
57
+ import dlf4p as dlf
55
58
 
56
59
  dlf.setup(time=True, color=True, simple=False, file_logging=True)
57
60
 
@@ -62,9 +65,9 @@ dlf.error("Database connection error", "Database")
62
65
  dlf.fatal("Critical error", "System")
63
66
  ```
64
67
 
65
- Example console output:
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
+
@@ -5,6 +5,9 @@ It provides a simple API for logging messages with support for log levels, color
5
5
 
6
6
  The project is being developed as part of the **DLF (Dexoron Logging Framework)** family, with plans for implementations in other programming languages.
7
7
 
8
+ GitLab repository: https://gitlab.com/dexoron/dlf4p
9
+ PyPi project: https://pypi.org/project/dlf4p
10
+
8
11
  ---
9
12
 
10
13
  ## Features
@@ -32,7 +35,7 @@ pip install dlf4p
32
35
  ## Quick Start
33
36
 
34
37
  ```python
35
- import dlf4p an dlf
38
+ import dlf4p as dlf
36
39
 
37
40
  dlf.setup(time=True, color=True, simple=False, file_logging=True)
38
41
 
@@ -43,9 +46,9 @@ dlf.error("Database connection error", "Database")
43
46
  dlf.fatal("Critical error", "System")
44
47
  ```
45
48
 
46
- Example console output:
49
+ Console output:
47
50
 
48
- ```
51
+ ```log
49
52
  [12:30:10] [Main/INFO]: Application started
50
53
  [12:30:11] [Server/SUCCESS]: Server successfully started
51
54
  [12:30:12] [API/WARNING]: Slow response
@@ -53,6 +56,31 @@ Example console output:
53
56
  [12:30:14] [System/FATAL]: Critical error
54
57
  ```
55
58
 
59
+ Logger class example:
60
+
61
+ ```python
62
+ import dlf4p as dlf
63
+
64
+ dlf.setup(time=True, color=True, simple=False, file_logging=True)
65
+
66
+ log = dlf.Logger("Main")
67
+ log.info("Application started")
68
+
69
+ log = dlf.Logger("Core")
70
+ log.setLevel(2) # SUCCESS and higher
71
+ log.info("Core module initialized")
72
+ log.success("Submodule loaded successfully")
73
+ log.warning("Disabled System modules")
74
+ ```
75
+
76
+ Console output:
77
+
78
+ ```log
79
+ [12:30:10] [Main/INFO]: Application started
80
+ [12:30:11] [Core/SUCCESS]: Submodule loaded successfully
81
+ [12:30:12] [Core/WARNING]: Disabled System modules
82
+ ```
83
+
56
84
  > Logs are saved to a file without ANSI color codes.
57
85
 
58
86
  ---
@@ -79,6 +107,16 @@ dlf.setup(
79
107
 
80
108
  ---
81
109
 
110
+ ## Run Example
111
+
112
+ From the project root:
113
+
114
+ ```bash
115
+ python3 -m test.main
116
+ ```
117
+
118
+ ---
119
+
82
120
  ## Philosophy
83
121
 
84
122
  `dlf4p` is inspired by **SLF4J (Simple Logging Facade for Java)** and aims to:
@@ -106,4 +144,13 @@ Website: [https://dexoron.su](https://dexoron.su)
106
144
 
107
145
  ---
108
146
 
109
- > dlf4p — a simple logger today, a full logging framework tomorrow.
147
+ ## Project Links
148
+
149
+ Changelog: `CHANGELOG`
150
+ Contributing guide: `CONTRIBUTING.md`
151
+ GitLab repository: https://gitlab.com/dexoron/dlf4p
152
+ PyPi project: https://pypi.org/project/dlf4p
153
+
154
+ ---
155
+
156
+ > dlf4p — a simple logger today, a full logging framework tomorrow.
@@ -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.1.0"
25
+ __version__ = "1.2.0"
@@ -0,0 +1,106 @@
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
+ )
16
+
17
+ LOG_FILENAME = None
18
+
19
+ def setup(time: bool=True, color: bool=True, simple: bool=False, file_logging: bool=True):
20
+ global useTime, useColor, simpleLog, logFile, LOG_FILENAME
21
+ useTime = time
22
+ useColor = color
23
+ simpleLog = simple
24
+ if file_logging:
25
+ LOG_FILENAME = f"logger-{get_data()}-{get_time()}.log"
26
+ def logFile(msg):
27
+ with open(LOG_FILENAME, "a") as log_handle:
28
+ log_handle.write(msg + "\n")
29
+ else:
30
+ def logFile(msg):
31
+ return None
32
+
33
+ def _print(level: int, prefix: str, content: str, color: str=None):
34
+ base_msg = ""
35
+
36
+ if useTime:
37
+ base_msg += f"[{get_time()}] "
38
+
39
+ if simpleLog or not prefix:
40
+ base_msg += f"[{level}]"
41
+ else:
42
+ base_msg += f"[{prefix}/{level}]"
43
+
44
+ base_msg += f": {str(content)}"
45
+
46
+ if useColor and color:
47
+ console_msg = f"{color}{base_msg}{reset}"
48
+ else:
49
+ console_msg = base_msg
50
+
51
+ print(console_msg)
52
+ logFile(base_msg)
53
+
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):
91
+ _print("DEBUG", prefix, content)
92
+
93
+ def info(content: str, prefix: str=None):
94
+ _print("INFO", prefix, content)
95
+
96
+ def success(content: str, prefix: str=None):
97
+ _print("SUCCESS", prefix, content, green)
98
+
99
+ def warning(content: str, prefix: str=None):
100
+ _print("WARNING", prefix, content, yellow)
101
+
102
+ def error(content: str, prefix: str=None):
103
+ _print("ERROR", prefix, content, red)
104
+
105
+ def fatal(content: str, prefix: str=None):
106
+ _print("FATAL", prefix, content, bold_red)
@@ -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,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dlf4p
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Dexoron Logging Framework for Python
5
- Home-page: https://gitlab.com/dexoron/dlf-py
5
+ Home-page: https://gitlab.com/dexoron/dlf4p
6
6
  Author: Dexoron
7
7
  Author-email: main@dexoron.su
8
8
  License: UNKNOWN
9
9
  Project-URL: Homepage, https://dexoron.su
10
- Project-URL: Repository, https://gitlab.com/dexoron/dlf-py
10
+ Project-URL: Repository, https://gitlab.com/dexoron/dlf4p
11
11
  Keywords: logging logger dlf dexoron
12
12
  Platform: UNKNOWN
13
13
  Classifier: Programming Language :: Python :: 3.10
@@ -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
@@ -51,7 +54,7 @@ pip install dlf4p
51
54
  ## Quick Start
52
55
 
53
56
  ```python
54
- import dlf4p an dlf
57
+ import dlf4p as dlf
55
58
 
56
59
  dlf.setup(time=True, color=True, simple=False, file_logging=True)
57
60
 
@@ -62,9 +65,9 @@ dlf.error("Database connection error", "Database")
62
65
  dlf.fatal("Critical error", "System")
63
66
  ```
64
67
 
65
- Example console output:
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
+
@@ -4,7 +4,10 @@ setup.cfg
4
4
  setup.py
5
5
  dlf4p/__init__.py
6
6
  dlf4p/logger.py
7
+ dlf4p/utils.py
7
8
  dlf4p.egg-info/PKG-INFO
8
9
  dlf4p.egg-info/SOURCES.txt
9
10
  dlf4p.egg-info/dependency_links.txt
10
- dlf4p.egg-info/top_level.txt
11
+ dlf4p.egg-info/top_level.txt
12
+ test/__init__.py
13
+ test/main.py
@@ -1 +1,2 @@
1
1
  dlf4p
2
+ test
@@ -8,13 +8,13 @@ def readme():
8
8
 
9
9
  setup(
10
10
  name="dlf4p",
11
- version="1.1.0",
11
+ version="1.2.0",
12
12
  author="Dexoron",
13
13
  author_email="main@dexoron.su",
14
14
  description="Dexoron Logging Framework for Python",
15
15
  long_description=readme(),
16
16
  long_description_content_type="text/markdown",
17
- url="https://gitlab.com/dexoron/dlf-py",
17
+ url="https://gitlab.com/dexoron/dlf4p",
18
18
  packages=find_packages(),
19
19
  install_requires=[],
20
20
  classifiers=[
@@ -25,7 +25,7 @@ setup(
25
25
  keywords="logging logger dlf dexoron",
26
26
  project_urls={
27
27
  "Homepage": "https://dexoron.su",
28
- "Repository": "https://gitlab.com/dexoron/dlf-py",
28
+ "Repository": "https://gitlab.com/dexoron/dlf4p",
29
29
  },
30
30
  python_requires=">=3.8",
31
31
  )
File without changes
@@ -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")
@@ -1,73 +0,0 @@
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)
File without changes
File without changes