logly 0.0.4__tar.gz → 0.0.7__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.
logly-0.0.7/PKG-INFO ADDED
@@ -0,0 +1,333 @@
1
+ Metadata-Version: 2.1
2
+ Name: logly
3
+ Version: 0.0.7
4
+ Summary: Logly: Ready to Go Python logging utility with color-coded messages, file-based logging, and many more customizable options. Simplify logging in your Python applications with Logly.
5
+ Home-page: https://github.com/muhammad-fiaz/logly.git
6
+ Author: Muhammad Fiaz
7
+ Author-email: contact@muhammmadfiaz.com
8
+ License: MIT License
9
+ Project-URL: Source Code, https://github.com/muhammad-fiaz/logly.git
10
+ Project-URL: Bug Tracker, https://github.com/muhammad-fiaz/logly/issues
11
+ Project-URL: Documentation, https://github.com/muhammad-fiaz/logly#readme
12
+ Keywords: logging,custom-logging,logly,logging-utility,python,logs
13
+ Platform: UNKNOWN
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: System :: Logging
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+
28
+ <div align="center">
29
+
30
+ <img src="assets/logly_logo.png" alt="Sample Image">
31
+
32
+
33
+ # Logly
34
+
35
+ [![Run Tests](https://github.com/muhammad-fiaz/logly/actions/workflows/python-package.yaml/badge.svg)](https://github.com/muhammad-fiaz/logly/actions/workflows/python-package.yaml)
36
+ [![PyPI Version](https://img.shields.io/pypi/v/logly)](https://pypi.org/project/logly/)
37
+ [![Python Versions](https://img.shields.io/pypi/pyversions/logly)](https://pypi.org/project/logly/)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
39
+ [![Downloads](https://img.shields.io/pypi/dm/logly)](https://pypi.org/project/logly/)
40
+ [![Last Commit](https://img.shields.io/github/last-commit/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly)
41
+ [![GitHub Issues](https://img.shields.io/github/issues/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly/issues)
42
+ [![GitHub Stars](https://img.shields.io/github/stars/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly/stargazers)
43
+ [![GitHub Forks](https://img.shields.io/github/forks/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly/network)
44
+ [![Maintainer](https://img.shields.io/badge/Maintainer-muhammad--fiaz-blue)](https://github.com/muhammad-fiaz)
45
+ [![Sponsor on GitHub](https://img.shields.io/badge/Sponsor%20on%20GitHub-Become%20a%20Sponsor-blue)](https://github.com/sponsors/muhammad-fiaz)
46
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
47
+ [![Stability](https://img.shields.io/badge/Stability-Stable-green)](https://github.com/muhammad-fiaz/logly)
48
+ [![Follow me on GitHub](https://img.shields.io/github/followers/muhammad-fiaz?label=Follow&style=social)](https://github.com/muhammad-fiaz)
49
+
50
+ [![Join My Discord](https://img.shields.io/badge/Join%20My%20Discord-7289DA?style=for-the-badge&logo=discord)](https://discord.gg/cFnFdeFw)
51
+ [![Sponsor muhammad-fiaz](https://img.shields.io/badge/Sponsor-muhammad_fiaz-ff69b4?style=for-the-badge&logo=github)](https://github.com/sponsors/muhammad-fiaz)
52
+
53
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F6MME1W)
54
+
55
+ </div>
56
+
57
+ Tired of writing custom logging code for your Python applications?
58
+
59
+ Logly is a ready to go logging utility that provides an easy way to log messages with different levels, colors, and many custom options. It is designed to be flexible, allowing you to customize the log messages based on your application's needs. Logly supports logging to both the console and a file, and it comes with built-in color-coded log levels for better visibility.
60
+
61
+ if you like this project, make sure to star 🌟 it in the [repository](https://github.com/muhammad-fiaz/logly/) and if you want to contribute make sure to fork this repository❤✨.
62
+
63
+ ## Table of Contents
64
+
65
+ 1. [Introduction](#)
66
+ 2. [Installation](#installation)
67
+ 3. [Features](#features)
68
+ 4. [Usage](#usage)
69
+ - [Getting Started](#getting-started)
70
+ 5. [Set Default Path](#set-default-path)
71
+ 6. [Color Options](#color-options)
72
+ - [Default Color Options](#default-color-options)
73
+ - [Custom Color Options](#custom-color-options)
74
+ 7. [Tips & Tricks](#tips--tricks)
75
+ 8. [Contributing](#contributing)
76
+ 9. [Code of Conduct](#code-of-conduct)
77
+ 10. [License](#license)
78
+ 11. [Support the Project](#support-the-project)
79
+ - [Become a Sponsor on GitHub](#become-a-sponsor-on-github)
80
+ - [Support via Ko-fi](#support-via-ko-fi)
81
+ 12. [Happy Coding](#happy-coding)
82
+
83
+
84
+ ## Features
85
+
86
+ - Easy-to-use logging for Python applications.
87
+ - Customizable log levels and formatting.
88
+ - Customizable log colors.
89
+ - Log to file and/or console.
90
+ - Log to file with automatic file rotation.
91
+ - Log to file with automatic file size management.
92
+ - Log to file with automatic file deletion.
93
+ - Log to file with automatic deletion and rewriting of the file when it reaches max_file_size.
94
+ - Open Source: Logly is an open-source project, and we welcome contributions from the community.
95
+ - Community Support: Join a community of developers using Logly for their logging needs.
96
+ - many more features!
97
+
98
+ ## Getting Started
99
+
100
+ ## Installation
101
+
102
+ To install the stable version of `logly`, use:
103
+ ```bash
104
+ pip install logly
105
+ ```
106
+
107
+ If you want to install the latest development version directly from GitHub, you can run:
108
+ ```bash
109
+ pip install git+https://github.com/muhammad-fiaz/logly.git
110
+ ```
111
+
112
+ ## Usage
113
+ Once installed, you can use `logly` in your Python project for logging. Here is a basic example of how to set it up and use it:
114
+ ```python
115
+ # Import Logly
116
+ from logly import Logly
117
+
118
+ # Create a Logly instance
119
+ logly = Logly()
120
+
121
+ # Start logging to store the logs in a text file
122
+ logly.start_logging() # Make sure to include this or else the logs will only display without being saved to a file
123
+
124
+ logly.info("Application started successfully.")
125
+ logly.info("User logged in", color=logly.COLOR.GREEN) # with custom color
126
+
127
+ # Log messages with different levels and colors
128
+ logly.info("Database connection established", "Connection details: host=db.local, port=5432", color=logly.COLOR.CYAN)
129
+ logly.warn("API rate limit exceeded", "API request count exceeded 1000", color=logly.COLOR.YELLOW)
130
+ logly.error("Database connection failed", "Unable to reach database at db.local", color=logly.COLOR.RED)
131
+ logly.debug("User request details", "User requested resource /api/data", color=logly.COLOR.BLUE)
132
+ logly.critical("Critical system failure", "Disk space usage exceeded 95%", color=logly.COLOR.CRITICAL)
133
+ logly.fatal("Application crashed", "Unhandled exception in user module", color=logly.COLOR.CRITICAL)
134
+ logly.trace("Debug trace", "Trace info: function call stack", color=logly.COLOR.BLUE)
135
+ logly.log("System status", "All systems operational", color=logly.COLOR.WHITE)
136
+
137
+ # Stop logging (messages will be displayed but not logged to file after this point)
138
+ logly.stop_logging()
139
+
140
+ # Log more messages after stopping logging (messages will be displayed but not logged in file)
141
+ logly.info("User session ended", "User logged out", color=logly.COLOR.CYAN)
142
+ logly.warn("Low disk space", "Disk space is below 10%", color=logly.COLOR.YELLOW)
143
+ logly.error("File not found", "Unable to find /config/settings.json", color=logly.COLOR.RED)
144
+
145
+ # Example of retrieving and printing a logged message
146
+ get_message = logly.info("New feature deployed", "Version 2.0 live now", color=logly.COLOR.RED)
147
+ print(get_message) # You can use the returned message in your application (optional)
148
+
149
+ # Log message with custom color and no timestamp
150
+ logly.info("Custom log without time", "This log message does not include a timestamp", color=logly.COLOR.RED, show_time=False)
151
+
152
+ # Start logging again
153
+ logly.start_logging()
154
+
155
+ # Set the default file path and max file size
156
+ logly.set_default_file_path("application_logs.txt") # Set the default file path
157
+ logly.set_default_max_file_size(50) # Set default max file size to 50 MB
158
+
159
+ # Log messages with default settings (using default file path and max file size)
160
+ logly.info("Default logging example", "Logging to default file path and size")
161
+ logly.warn("File logging size test", "Max file size set to 50 MB", log_to_file=False)
162
+
163
+ # Log messages with custom file path and max file size (optional)
164
+ logly.info("Logging with custom file path", "This will create a new log file", file_path="logs/custom_log.txt", max_file_size=25)
165
+ logly.warn("Auto file size management", "Log file will be auto-deleted when size exceeds limit", file_path="logs/auto_delete_log.txt", max_file_size=25, auto=True)
166
+
167
+ # Access color constants directly for logging
168
+ logly.info("Using color constants directly", "This message is in red", color=logly.COLOR.RED)
169
+
170
+ # Disable color for logging
171
+ logly.color_enabled = False
172
+ logly.info("Logging without color", "This log message is displayed without color", color=logly.COLOR.RED)
173
+
174
+ # Enable color for specific log message
175
+ logly.info("Enable color for this message", "This message will have color", color=logly.COLOR.RED, color_enabled=True)
176
+
177
+ # Disable color for specific log message
178
+ logly.info("Disable color for this message", "This message will be displayed without color", color=logly.COLOR.RED, color_enabled=False)
179
+
180
+ # Display logged messages (this will display all the messages logged so far)
181
+ print("Logged Messages:")
182
+ for message in logly.logged_messages:
183
+ print(message)
184
+
185
+ ```
186
+
187
+ for more information, check the [repository](https://github.com/muhammad-fiaz/logly)
188
+
189
+ ## Set the Default Path
190
+
191
+ If you encounter an error related to the default file path, you can use the following code snippet to set the default path:
192
+
193
+ ```python3
194
+ import os
195
+ from logly import Logly
196
+
197
+ logly = Logly()
198
+ logly.start_logging()
199
+
200
+ # Set the default file path and maximum file size
201
+ logly.set_default_max_file_size(50)
202
+ logger = os.path.join(os.path.dirname(os.path.abspath(__file__)), "log.txt")
203
+ logly.set_default_file_path(logger)
204
+ ```
205
+ This will set the default file path, and you can customize it according to your requirements.
206
+
207
+ if you want to set the default path for the log file, you can use the following code snippet
208
+
209
+ ```python3
210
+ from logly import Logly
211
+ logly = Logly()
212
+ logly.set_default_file_path("log.txt")
213
+ ```
214
+
215
+ if you faced an error like [`FileNotFoundError: [Errno 2] No such file or directory: 'log.txt'`](https://github.com/muhammad-fiaz/logly/issues/4) you can use the following code snippet to set the default path
216
+
217
+ ```python3
218
+ import os
219
+ from logly import Logly
220
+
221
+ logly = Logly() # initialize the logly
222
+ logly.start_logging() # make sure to include this or else the log will only display without storing it
223
+
224
+ logly.set_default_max_file_size(50) # optional
225
+ logger = os.path.join(os.path.dirname(os.path.abspath(__file__)), "log.txt") # This will ensure the path location to create the log.txt on current directory
226
+ logly.set_default_file_path(logger)
227
+ ```
228
+ for more information, check the [repository](https://github.com/muhammad-fiaz/logly).
229
+
230
+ ## Color Options:
231
+
232
+ ### Default Color Options:
233
+
234
+ | Level | Color Code |
235
+ | -------- | --------------- |
236
+ | INFO | CYAN |
237
+ | WARNING | YELLOW |
238
+ | ERROR | RED |
239
+ | DEBUG | BLUE |
240
+ | CRITICAL | BRIGHT RED |
241
+ | TRACE | BLUE |
242
+ | DEFAULT | WHITE |
243
+
244
+ ### Custom Color Options:
245
+
246
+ You can use any of the following color codes for custom coloring:
247
+
248
+ | NAME | Color Code |
249
+ |----------| --------------- |
250
+ | CYAN | CYAN |
251
+ | YELLOW | YELLOW |
252
+ | RED | RED |
253
+ | BLUE | BLUE |
254
+ | BRIGHT RED | CRITICAL |
255
+ |WHITE | WHITE |
256
+
257
+ For example, you can use `color=logly.COLOR.RED` for the red color.
258
+
259
+ ## Tips & Tricks
260
+ If you want to use logly in your project files without creating a new object in each Python file or class, you can create a file named logly.py. In this file, initialize logly and configure the defaults. Now, you can easily import and use it throughout your project:
261
+
262
+ `logly.py`
263
+ ```python3
264
+ # logly.py in your root or custom path
265
+ # Import Logly
266
+
267
+ from logly import Logly
268
+ import os
269
+ logly = Logly()
270
+ logly.start_logging()
271
+
272
+ # Set the default file path and maximum file size
273
+ logly.set_default_max_file_size(50)
274
+ logger = os.path.join(os.path.dirname(os.path.abspath(__file__)), "log.txt") # This will ensure the path location to create the log.txt
275
+ logly.set_default_file_path(logger)
276
+
277
+ # Start logging again
278
+ logly.start_logging()
279
+ ```
280
+ you can now use the logly by
281
+
282
+
283
+ `main.py`
284
+ ```python3
285
+ from logly import logly # make sure to import it some IDE may automatically import it on top
286
+
287
+ logly.info("msg","hello this is logly", color=logly.COLOR.RED) # with custom color of red
288
+
289
+ ```
290
+ ### output
291
+ ```
292
+ [XXXX-XX-XX XX:XX: XX] INFO: msg: hello this is logly
293
+
294
+ ```
295
+
296
+ ## Contributing
297
+ Contributions are welcome! Before contributing, please read our [Contributing Guidelines](CONTRIBUTING.md) to ensure a smooth and collaborative development process.
298
+
299
+ ## Code of Conduct
300
+
301
+ Please review our [Code of Conduct](CODE_OF_CONDUCT.md) to understand the standards of behavior we expect from contributors and users of this project.
302
+
303
+ ## License
304
+ This project is licensed under the [MIT License](). See [LICENSE](LICENSE) for more details.
305
+
306
+
307
+ ## Support the Project
308
+
309
+ <div align="center">
310
+
311
+ Your support helps improve Logly and enables us to continue adding more features and improvements. If you'd like to contribute and support the development of this project, consider becoming a sponsor on GitHub or Ko-fi.
312
+
313
+
314
+
315
+
316
+ ### Become a Sponsor on GitHub
317
+ Support Logly directly on GitHub to help sustain ongoing development.
318
+
319
+ [![Sponsor muhammad-fiaz](https://img.shields.io/badge/Sponsor-%231EAEDB.svg?&style=for-the-badge&logo=GitHub-Sponsors&logoColor=white)](https://github.com/sponsors/muhammad-fiaz)
320
+
321
+ ### Support via Ko-fi
322
+ If you prefer, you can also support the project via Ko-fi.
323
+
324
+ [![Support on Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F6MME1W)
325
+
326
+
327
+ Thank you for supporting the project! 🙏
328
+
329
+ </div>
330
+
331
+ ## Happy Coding
332
+
333
+
logly-0.0.7/README.md ADDED
@@ -0,0 +1,304 @@
1
+ <div align="center">
2
+
3
+ <img src="assets/logly_logo.png" alt="Sample Image">
4
+
5
+
6
+ # Logly
7
+
8
+ [![Run Tests](https://github.com/muhammad-fiaz/logly/actions/workflows/python-package.yaml/badge.svg)](https://github.com/muhammad-fiaz/logly/actions/workflows/python-package.yaml)
9
+ [![PyPI Version](https://img.shields.io/pypi/v/logly)](https://pypi.org/project/logly/)
10
+ [![Python Versions](https://img.shields.io/pypi/pyversions/logly)](https://pypi.org/project/logly/)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
12
+ [![Downloads](https://img.shields.io/pypi/dm/logly)](https://pypi.org/project/logly/)
13
+ [![Last Commit](https://img.shields.io/github/last-commit/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly)
14
+ [![GitHub Issues](https://img.shields.io/github/issues/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly/issues)
15
+ [![GitHub Stars](https://img.shields.io/github/stars/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly/stargazers)
16
+ [![GitHub Forks](https://img.shields.io/github/forks/muhammad-fiaz/logly)](https://github.com/muhammad-fiaz/logly/network)
17
+ [![Maintainer](https://img.shields.io/badge/Maintainer-muhammad--fiaz-blue)](https://github.com/muhammad-fiaz)
18
+ [![Sponsor on GitHub](https://img.shields.io/badge/Sponsor%20on%20GitHub-Become%20a%20Sponsor-blue)](https://github.com/sponsors/muhammad-fiaz)
19
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
20
+ [![Stability](https://img.shields.io/badge/Stability-Stable-green)](https://github.com/muhammad-fiaz/logly)
21
+ [![Follow me on GitHub](https://img.shields.io/github/followers/muhammad-fiaz?label=Follow&style=social)](https://github.com/muhammad-fiaz)
22
+
23
+ [![Join My Discord](https://img.shields.io/badge/Join%20My%20Discord-7289DA?style=for-the-badge&logo=discord)](https://discord.gg/cFnFdeFw)
24
+ [![Sponsor muhammad-fiaz](https://img.shields.io/badge/Sponsor-muhammad_fiaz-ff69b4?style=for-the-badge&logo=github)](https://github.com/sponsors/muhammad-fiaz)
25
+
26
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F6MME1W)
27
+
28
+ </div>
29
+
30
+ Tired of writing custom logging code for your Python applications?
31
+
32
+ Logly is a ready to go logging utility that provides an easy way to log messages with different levels, colors, and many custom options. It is designed to be flexible, allowing you to customize the log messages based on your application's needs. Logly supports logging to both the console and a file, and it comes with built-in color-coded log levels for better visibility.
33
+
34
+ if you like this project, make sure to star 🌟 it in the [repository](https://github.com/muhammad-fiaz/logly/) and if you want to contribute make sure to fork this repository❤✨.
35
+
36
+ ## Table of Contents
37
+
38
+ 1. [Introduction](#)
39
+ 2. [Installation](#installation)
40
+ 3. [Features](#features)
41
+ 4. [Usage](#usage)
42
+ - [Getting Started](#getting-started)
43
+ 5. [Set Default Path](#set-default-path)
44
+ 6. [Color Options](#color-options)
45
+ - [Default Color Options](#default-color-options)
46
+ - [Custom Color Options](#custom-color-options)
47
+ 7. [Tips & Tricks](#tips--tricks)
48
+ 8. [Contributing](#contributing)
49
+ 9. [Code of Conduct](#code-of-conduct)
50
+ 10. [License](#license)
51
+ 11. [Support the Project](#support-the-project)
52
+ - [Become a Sponsor on GitHub](#become-a-sponsor-on-github)
53
+ - [Support via Ko-fi](#support-via-ko-fi)
54
+ 12. [Happy Coding](#happy-coding)
55
+
56
+
57
+ ## Features
58
+
59
+ - Easy-to-use logging for Python applications.
60
+ - Customizable log levels and formatting.
61
+ - Customizable log colors.
62
+ - Log to file and/or console.
63
+ - Log to file with automatic file rotation.
64
+ - Log to file with automatic file size management.
65
+ - Log to file with automatic file deletion.
66
+ - Log to file with automatic deletion and rewriting of the file when it reaches max_file_size.
67
+ - Open Source: Logly is an open-source project, and we welcome contributions from the community.
68
+ - Community Support: Join a community of developers using Logly for their logging needs.
69
+ - many more features!
70
+
71
+ ## Getting Started
72
+
73
+ ## Installation
74
+
75
+ To install the stable version of `logly`, use:
76
+ ```bash
77
+ pip install logly
78
+ ```
79
+
80
+ If you want to install the latest development version directly from GitHub, you can run:
81
+ ```bash
82
+ pip install git+https://github.com/muhammad-fiaz/logly.git
83
+ ```
84
+
85
+ ## Usage
86
+ Once installed, you can use `logly` in your Python project for logging. Here is a basic example of how to set it up and use it:
87
+ ```python
88
+ # Import Logly
89
+ from logly import Logly
90
+
91
+ # Create a Logly instance
92
+ logly = Logly()
93
+
94
+ # Start logging to store the logs in a text file
95
+ logly.start_logging() # Make sure to include this or else the logs will only display without being saved to a file
96
+
97
+ logly.info("Application started successfully.")
98
+ logly.info("User logged in", color=logly.COLOR.GREEN) # with custom color
99
+
100
+ # Log messages with different levels and colors
101
+ logly.info("Database connection established", "Connection details: host=db.local, port=5432", color=logly.COLOR.CYAN)
102
+ logly.warn("API rate limit exceeded", "API request count exceeded 1000", color=logly.COLOR.YELLOW)
103
+ logly.error("Database connection failed", "Unable to reach database at db.local", color=logly.COLOR.RED)
104
+ logly.debug("User request details", "User requested resource /api/data", color=logly.COLOR.BLUE)
105
+ logly.critical("Critical system failure", "Disk space usage exceeded 95%", color=logly.COLOR.CRITICAL)
106
+ logly.fatal("Application crashed", "Unhandled exception in user module", color=logly.COLOR.CRITICAL)
107
+ logly.trace("Debug trace", "Trace info: function call stack", color=logly.COLOR.BLUE)
108
+ logly.log("System status", "All systems operational", color=logly.COLOR.WHITE)
109
+
110
+ # Stop logging (messages will be displayed but not logged to file after this point)
111
+ logly.stop_logging()
112
+
113
+ # Log more messages after stopping logging (messages will be displayed but not logged in file)
114
+ logly.info("User session ended", "User logged out", color=logly.COLOR.CYAN)
115
+ logly.warn("Low disk space", "Disk space is below 10%", color=logly.COLOR.YELLOW)
116
+ logly.error("File not found", "Unable to find /config/settings.json", color=logly.COLOR.RED)
117
+
118
+ # Example of retrieving and printing a logged message
119
+ get_message = logly.info("New feature deployed", "Version 2.0 live now", color=logly.COLOR.RED)
120
+ print(get_message) # You can use the returned message in your application (optional)
121
+
122
+ # Log message with custom color and no timestamp
123
+ logly.info("Custom log without time", "This log message does not include a timestamp", color=logly.COLOR.RED, show_time=False)
124
+
125
+ # Start logging again
126
+ logly.start_logging()
127
+
128
+ # Set the default file path and max file size
129
+ logly.set_default_file_path("application_logs.txt") # Set the default file path
130
+ logly.set_default_max_file_size(50) # Set default max file size to 50 MB
131
+
132
+ # Log messages with default settings (using default file path and max file size)
133
+ logly.info("Default logging example", "Logging to default file path and size")
134
+ logly.warn("File logging size test", "Max file size set to 50 MB", log_to_file=False)
135
+
136
+ # Log messages with custom file path and max file size (optional)
137
+ logly.info("Logging with custom file path", "This will create a new log file", file_path="logs/custom_log.txt", max_file_size=25)
138
+ logly.warn("Auto file size management", "Log file will be auto-deleted when size exceeds limit", file_path="logs/auto_delete_log.txt", max_file_size=25, auto=True)
139
+
140
+ # Access color constants directly for logging
141
+ logly.info("Using color constants directly", "This message is in red", color=logly.COLOR.RED)
142
+
143
+ # Disable color for logging
144
+ logly.color_enabled = False
145
+ logly.info("Logging without color", "This log message is displayed without color", color=logly.COLOR.RED)
146
+
147
+ # Enable color for specific log message
148
+ logly.info("Enable color for this message", "This message will have color", color=logly.COLOR.RED, color_enabled=True)
149
+
150
+ # Disable color for specific log message
151
+ logly.info("Disable color for this message", "This message will be displayed without color", color=logly.COLOR.RED, color_enabled=False)
152
+
153
+ # Display logged messages (this will display all the messages logged so far)
154
+ print("Logged Messages:")
155
+ for message in logly.logged_messages:
156
+ print(message)
157
+
158
+ ```
159
+
160
+ for more information, check the [repository](https://github.com/muhammad-fiaz/logly)
161
+
162
+ ## Set the Default Path
163
+
164
+ If you encounter an error related to the default file path, you can use the following code snippet to set the default path:
165
+
166
+ ```python3
167
+ import os
168
+ from logly import Logly
169
+
170
+ logly = Logly()
171
+ logly.start_logging()
172
+
173
+ # Set the default file path and maximum file size
174
+ logly.set_default_max_file_size(50)
175
+ logger = os.path.join(os.path.dirname(os.path.abspath(__file__)), "log.txt")
176
+ logly.set_default_file_path(logger)
177
+ ```
178
+ This will set the default file path, and you can customize it according to your requirements.
179
+
180
+ if you want to set the default path for the log file, you can use the following code snippet
181
+
182
+ ```python3
183
+ from logly import Logly
184
+ logly = Logly()
185
+ logly.set_default_file_path("log.txt")
186
+ ```
187
+
188
+ if you faced an error like [`FileNotFoundError: [Errno 2] No such file or directory: 'log.txt'`](https://github.com/muhammad-fiaz/logly/issues/4) you can use the following code snippet to set the default path
189
+
190
+ ```python3
191
+ import os
192
+ from logly import Logly
193
+
194
+ logly = Logly() # initialize the logly
195
+ logly.start_logging() # make sure to include this or else the log will only display without storing it
196
+
197
+ logly.set_default_max_file_size(50) # optional
198
+ logger = os.path.join(os.path.dirname(os.path.abspath(__file__)), "log.txt") # This will ensure the path location to create the log.txt on current directory
199
+ logly.set_default_file_path(logger)
200
+ ```
201
+ for more information, check the [repository](https://github.com/muhammad-fiaz/logly).
202
+
203
+ ## Color Options:
204
+
205
+ ### Default Color Options:
206
+
207
+ | Level | Color Code |
208
+ | -------- | --------------- |
209
+ | INFO | CYAN |
210
+ | WARNING | YELLOW |
211
+ | ERROR | RED |
212
+ | DEBUG | BLUE |
213
+ | CRITICAL | BRIGHT RED |
214
+ | TRACE | BLUE |
215
+ | DEFAULT | WHITE |
216
+
217
+ ### Custom Color Options:
218
+
219
+ You can use any of the following color codes for custom coloring:
220
+
221
+ | NAME | Color Code |
222
+ |----------| --------------- |
223
+ | CYAN | CYAN |
224
+ | YELLOW | YELLOW |
225
+ | RED | RED |
226
+ | BLUE | BLUE |
227
+ | BRIGHT RED | CRITICAL |
228
+ |WHITE | WHITE |
229
+
230
+ For example, you can use `color=logly.COLOR.RED` for the red color.
231
+
232
+ ## Tips & Tricks
233
+ If you want to use logly in your project files without creating a new object in each Python file or class, you can create a file named logly.py. In this file, initialize logly and configure the defaults. Now, you can easily import and use it throughout your project:
234
+
235
+ `logly.py`
236
+ ```python3
237
+ # logly.py in your root or custom path
238
+ # Import Logly
239
+
240
+ from logly import Logly
241
+ import os
242
+ logly = Logly()
243
+ logly.start_logging()
244
+
245
+ # Set the default file path and maximum file size
246
+ logly.set_default_max_file_size(50)
247
+ logger = os.path.join(os.path.dirname(os.path.abspath(__file__)), "log.txt") # This will ensure the path location to create the log.txt
248
+ logly.set_default_file_path(logger)
249
+
250
+ # Start logging again
251
+ logly.start_logging()
252
+ ```
253
+ you can now use the logly by
254
+
255
+
256
+ `main.py`
257
+ ```python3
258
+ from logly import logly # make sure to import it some IDE may automatically import it on top
259
+
260
+ logly.info("msg","hello this is logly", color=logly.COLOR.RED) # with custom color of red
261
+
262
+ ```
263
+ ### output
264
+ ```
265
+ [XXXX-XX-XX XX:XX: XX] INFO: msg: hello this is logly
266
+
267
+ ```
268
+
269
+ ## Contributing
270
+ Contributions are welcome! Before contributing, please read our [Contributing Guidelines](CONTRIBUTING.md) to ensure a smooth and collaborative development process.
271
+
272
+ ## Code of Conduct
273
+
274
+ Please review our [Code of Conduct](CODE_OF_CONDUCT.md) to understand the standards of behavior we expect from contributors and users of this project.
275
+
276
+ ## License
277
+ This project is licensed under the [MIT License](). See [LICENSE](LICENSE) for more details.
278
+
279
+
280
+ ## Support the Project
281
+
282
+ <div align="center">
283
+
284
+ Your support helps improve Logly and enables us to continue adding more features and improvements. If you'd like to contribute and support the development of this project, consider becoming a sponsor on GitHub or Ko-fi.
285
+
286
+
287
+
288
+
289
+ ### Become a Sponsor on GitHub
290
+ Support Logly directly on GitHub to help sustain ongoing development.
291
+
292
+ [![Sponsor muhammad-fiaz](https://img.shields.io/badge/Sponsor-%231EAEDB.svg?&style=for-the-badge&logo=GitHub-Sponsors&logoColor=white)](https://github.com/sponsors/muhammad-fiaz)
293
+
294
+ ### Support via Ko-fi
295
+ If you prefer, you can also support the project via Ko-fi.
296
+
297
+ [![Support on Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F6MME1W)
298
+
299
+
300
+ Thank you for supporting the project! 🙏
301
+
302
+ </div>
303
+
304
+ ## Happy Coding
@@ -1,6 +1,6 @@
1
1
  # Example usage:
2
2
  """
3
- Logly: A simple logging utility.
3
+ Logly: A ready to go logging utility.
4
4
 
5
5
  Copyright (c) 2023 Muhammad Fiaz
6
6
 
@@ -1,5 +1,5 @@
1
1
  """
2
- Logly: A simple logging utility.
2
+ Logly: A ready to go logging utility.
3
3
 
4
4
  Copyright (c) 2023 Muhammad Fiaz
5
5