# ObjLog
> logging, Objectified
## Notice
This repo is a living repository, and the master branch is not guaranteed to be stable. If you want to use this library in a project, please use a release version, or a tagged commit.
It is always in the works, and new features are being added all the time!
## what is this?
This is a logging library for python. It is designed to be simple to use, and easy to understand.
## how do I use it?
You can use it like this:
```python
from objlog import LogNode
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="Basic Example", print_to_console=True)
log.log(Debug("this is a debug message"))
log.log(Info("this is an info message"))
log.log(Warn("this is a warning message"))
log.log(Error("this is an error message"))
log.log(Fatal("this is a fatal message"))
```
output:
```shell
[Basic Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message
[Basic Example] [2023-12-08 08:36:33.155] INFO: This is an info message
[Basic Example] [2023-12-08 08:36:33.155] WARN: This is a warning message
[Basic Example] [2023-12-08 08:36:33.155] ERROR: This is an error message
[Basic Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message
```
(it's even colored in the console!)
## This is cool, but I want to do more!
### I want to log to a file!
```python
from objlog import LogNode
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="File Example", print_to_console=True, log_file="example.log")
log.log(Debug("this is a debug message"))
log.log(Info("this is an info message"))
log.log(Warn("this is a warning message"))
log.log(Error("this is an error message"))
log.log(Fatal("this is a fatal message"))
```
output:
```shell
[File Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message
[File Example] [2023-12-08 08:36:33.155] INFO: This is an info message
[File Example] [2023-12-08 08:36:33.155] WARN: This is a warning message
[File Example] [2023-12-08 08:36:33.155] ERROR: This is an error message
[File Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message
```
example.log:
```shell
[File Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message
[File Example] [2023-12-08 08:36:33.155] INFO: This is an info message
[File Example] [2023-12-08 08:36:33.155] WARN: This is a warning message
[File Example] [2023-12-08 08:36:33.155] ERROR: This is an error message
[File Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message
```
### I want a custom log message type!
```python
from objlog import LogNode, LogMessage
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
class CustomMessage(LogMessage):
color = "\033[32" # green
level = "CUSTOM"
log = LogNode(name="Custom Example", print_to_console=True)
log.log(CustomMessage("this is a custom message"))
```
output:
```shell
[Custom Example] [2023-12-08 08:36:33.155] CUSTOM: This is a custom message
```
(colored green in the console!)
### I want to log messages, but not print them to the console or a log file, than when I'm done, I want to print them all at once!
```python
from objlog import LogNode, LogMessage
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="Buffered Example")
log.log(Debug("this is a debug message"))
log.log(Info("this is an info message"))
log.log(Warn("this is a warning message"))
log.log(Error("this is an error message"))
log.log(Fatal("this is a fatal message"))
log.dump_messages("example.log") # this will not print the messages to the console, but save them to a file
# or
log.dump_messages_to_console() # this will print the messages to the console, but not save them to a file
# you can do both if you want!
# if you would like to continue logging after dumping the messages, you can do that too!
```
output:
```shell
[Buffered Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message
[Buffered Example] [2023-12-08 08:36:33.155] INFO: This is an info message
[Buffered Example] [2023-12-08 08:36:33.155] WARN: This is a warning message
[Buffered Example] [2023-12-08 08:36:33.155] ERROR: This is an error message
[Buffered Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message
```
example.log:
```shell
[Buffered Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message
[Buffered Example] [2023-12-08 08:36:33.155] INFO: This is an info message
[Buffered Example] [2023-12-08 08:36:33.155] WARN: This is a warning message
[Buffered Example] [2023-12-08 08:36:33.155] ERROR: This is an error message
[Buffered Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message
```
### Amazing! How do I filter messages?
```python
from objlog import LogNode, LogMessage
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="Filter Example")
log.log(Debug("this is a debug message"))
log.log(Info("this is an info message"))
log.log(Warn("this is a warning message"))
log.log(Error("this is an error message"))
log.log(Fatal("this is a fatal message"))
log.dump_messages("example.log", elementfilter=[Warn, Error, Fatal]) # this will not print the messages to the console, but save them to a file if they are a warning, error, or fatal
# the rest of the messages will not be saved to the file
# you can do the same thing with dump_messages_to_console()
log.dump_messages_to_console(Warn, Error, Fatal)
# you can also filter the log in-place
log.filter(typefilter=[Warn, Error, Fatal]) # this will remove all messages that are not a warning, error, or fatal from the log's memory
# you can also use the filter method to filter the logfile
log.filter(typefilter=[Warn, Error, Fatal], filter_logfiles=True) # this will remove all messages that are not a warning, error, or fatal from the log's memory, and overwrite the logfile with the filtered messages
# it even works with custom message types!
class CustomMessage(LogMessage):
color = "\033[32" # green
level = "CUSTOM"
log.log(CustomMessage("this is a custom message"))
log.log(CustomMessage("this is another custom message"))
log.log(Info("this is an info message"))
log.dump_messages_to_console(elementfilter=[CustomMessage]) # this will only print the custom messages to the console
# output:
# [Filter Example] [2023-12-08 08:36:33.155] CUSTOM: This is a custom message
# [Filter Example] [2023-12-08 08:36:33.155] CUSTOM: This is another custom message
```
### I want to not have a log file, and then I want to switch to having a log file (and store my old messages in it)!
```python
from objlog import LogNode, LogMessage
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="Switch Example") # no log file
log.log(Debug("this is a debug message"))
log.log(Info("this is an info message"))
log.log(Warn("this is a warning message"))
log.log(Error("this is an error message"))
log.log(Fatal("this is a fatal message"))
log.set_output_file("example.log") # now there is a log file, all new messages will be saved to it
log.log(Debug("this is a debug message 2")) # this message will be saved to the log file
log.log(Info("this is an info message 2")) # this message will be saved to the log file
log.log(Warn("this is a warning message 2")) # this message will be saved to the log file
log.log(Error("this is an error message 2")) # this message will be saved to the log file
log.log(Fatal("this is a fatal message 2")) # this message will be saved to the log file
# the messages before the log file was set will not be saved to the log file
# to move the old messages to the log file, you can do this:
log.set_output_file("example2.log", preserve_old_messages=True) # now the old messages will be saved to the log file, and all new messages will be saved to it as well
log.log(Debug("this is a debug message 3")) # this message will be saved to the log file
```
example.log:
```shell
[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2
[Switch Example] [2023-12-08 08:36:33.155] INFO: This is an info message 2
[Switch Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 2
[Switch Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 2
[Switch Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 2
```
example2.log:
```shell
[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message
[Switch Example] [2023-12-08 08:36:33.155] INFO: This is an info message
[Switch Example] [2023-12-08 08:36:33.155] WARN: This is a warning message
[Switch Example] [2023-12-08 08:36:33.155] ERROR: This is an error message
[Switch Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message
[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2
[Switch Example] [2023-12-08 08:36:33.155] INFO: This is an info message 2
[Switch Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 2
[Switch Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 2
[Switch Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 2
[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 3
```
### I have a very limited amount of RAM, and I want to limit the amount of messages that are stored in memory!
```python
from objlog import LogNode
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="Limited Example", max_messages_in_memory=5, log_file="limited.log") # only store 5 messages in memory
log.log(Debug("this is a debug message 1"))
log.log(Info("this is an info message 1"))
log.log(Warn("this is a warning message 1"))
log.log(Error("this is an error message 1"))
log.log(Fatal("this is a fatal message 1"))
log.log(Debug("this is a debug message 2")) # this message will be stored in memory, and the oldest message will be removed from memory
```
limited.log:
```shell
[Limited Example] [2023-12-08 08:36:33.155] INFO: This is an info message 1
[Limited Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 1
[Limited Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 1
[Limited Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 1
[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2
```
### I have a limited amount of SSD space, and I want to limit the amount of messages that are stored in the log file!
```python
from objlog import LogNode
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="Limited Example", max_log_messages=5, log_file="limited.log") # only store 5 messages in the log file, but unlimited messages in memory
log.log(Debug("this is a debug message 1"))
log.log(Info("this is an info message 1"))
log.log(Warn("this is a warning message 1"))
log.log(Error("this is an error message 1"))
log.log(Fatal("this is a fatal message 1"))
log.log(Debug("this is a debug message 2")) # this message will be stored in the log, and the oldest message will be removed from the log
log.dump_messages_to_console() # this will print all messages in memory to the console (including ones not saved to the log), but not save them to the log file
# to limit both the amount of messages in memory and the amount of messages in the log file, you can do this:
log = LogNode(name="Limited Example", max_messages_in_memory=5, max_log_messages=5, log_file="limited.log") # only store 5 messages in the log file, and only store 5 messages in memory
```
output:
```shell
[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 1
[Limited Example] [2023-12-08 08:36:33.155] INFO: This is an info message 1
[Limited Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 1
[Limited Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 1
[Limited Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 1
[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2
```
limited.log:
```shell
[Limited Example] [2023-12-08 08:36:33.155] INFO: This is an info message 1
[Limited Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 1
[Limited Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 1
[Limited Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 1
[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2
```
### I want to log messages, but I don't want to print them to the console or a log file, and I don't want to store them in memory!
1, that's useless why? and 2, you can do that!
```python
from objlog import LogNode
from objlog.LogMessages import Debug, Info, Warn, Error, Fatal
log = LogNode(name="Buffered Example", max_messages_in_memory=0)
log.log(Debug("this is a debug message"))
log.log(Info("this is an info message"))
log.log(Warn("this is a warning message"))
log.log(Error("this is an error message"))
log.log(Fatal("this is a fatal message"))
```
output:
```shell
```
## I want more examples!
check out the [examples](examples) folder within this project, plenty of examples there!
## I want to use this in a project!
Feel free to! This project is licensed under the Zlib license, so you can use it in any project, commercial or not, as long as you give credit to the original author (me) and don't claim it as your own.
## I want to contribute!
Feel free to!
Fork the repo, make your changes, and submit a pull request!
I'll review it, and if it's good, I'll merge it!
(for more information, see [CONTRIBUTING](CONTRIBUTING.md))
## I want to report a bug or request a feature!
Feel free to! Just open an issue, and I'll look into it!
## I found a security vulnerability!
Please don't open an issue for that! Instead, either make a pull request with the fix, or submit a vulnerability report! please read [SECURITY](SECURITY.md) for more information.
Raw data
{
"_id": null,
"home_page": "https://github.com/Kokonico/ObjLog",
"name": "ObjLog",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "logging, object, objectified, log, logger, loggers, OOP, python, python3, python3.10, python3.11, python3.12",
"author": "Kokonico",
"author_email": "kokonico@duck.com",
"download_url": "https://files.pythonhosted.org/packages/45/70/367cc336e7f96f98b22704c788a55271293140cbd60c96a1bd4a8a239b09/objlog-2.1.5.tar.gz",
"platform": null,
"description": "# ObjLog\n> logging, Objectified\n\n## Notice\n\nThis repo is a living repository, and the master branch is not guaranteed to be stable. If you want to use this library in a project, please use a release version, or a tagged commit.\nIt is always in the works, and new features are being added all the time!\n\n## what is this?\nThis is a logging library for python. It is designed to be simple to use, and easy to understand.\n\n## how do I use it?\nYou can use it like this:\n\n```python\nfrom objlog import LogNode\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"Basic Example\", print_to_console=True)\n\nlog.log(Debug(\"this is a debug message\"))\nlog.log(Info(\"this is an info message\"))\nlog.log(Warn(\"this is a warning message\"))\nlog.log(Error(\"this is an error message\"))\nlog.log(Fatal(\"this is a fatal message\"))\n```\n\noutput:\n```shell\n[Basic Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message\n[Basic Example] [2023-12-08 08:36:33.155] INFO: This is an info message\n[Basic Example] [2023-12-08 08:36:33.155] WARN: This is a warning message\n[Basic Example] [2023-12-08 08:36:33.155] ERROR: This is an error message\n[Basic Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message\n```\n\n(it's even colored in the console!)\n\n## This is cool, but I want to do more!\n\n### I want to log to a file!\n\n```python\nfrom objlog import LogNode\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"File Example\", print_to_console=True, log_file=\"example.log\")\n\nlog.log(Debug(\"this is a debug message\"))\nlog.log(Info(\"this is an info message\"))\nlog.log(Warn(\"this is a warning message\"))\nlog.log(Error(\"this is an error message\"))\nlog.log(Fatal(\"this is a fatal message\"))\n```\n\noutput:\n```shell\n[File Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message\n[File Example] [2023-12-08 08:36:33.155] INFO: This is an info message\n[File Example] [2023-12-08 08:36:33.155] WARN: This is a warning message\n[File Example] [2023-12-08 08:36:33.155] ERROR: This is an error message\n[File Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message\n```\n\nexample.log:\n```shell\n[File Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message\n[File Example] [2023-12-08 08:36:33.155] INFO: This is an info message\n[File Example] [2023-12-08 08:36:33.155] WARN: This is a warning message\n[File Example] [2023-12-08 08:36:33.155] ERROR: This is an error message\n[File Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message\n```\n\n### I want a custom log message type!\n\n```python\nfrom objlog import LogNode, LogMessage\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nclass CustomMessage(LogMessage):\n color = \"\\033[32\" # green\n level = \"CUSTOM\"\n\nlog = LogNode(name=\"Custom Example\", print_to_console=True)\n\nlog.log(CustomMessage(\"this is a custom message\"))\n```\n\noutput:\n```shell\n[Custom Example] [2023-12-08 08:36:33.155] CUSTOM: This is a custom message\n```\n\n(colored green in the console!)\n\n\n### I want to log messages, but not print them to the console or a log file, than when I'm done, I want to print them all at once!\n\n```python\nfrom objlog import LogNode, LogMessage\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"Buffered Example\")\n\nlog.log(Debug(\"this is a debug message\"))\nlog.log(Info(\"this is an info message\"))\nlog.log(Warn(\"this is a warning message\"))\nlog.log(Error(\"this is an error message\"))\nlog.log(Fatal(\"this is a fatal message\"))\n\nlog.dump_messages(\"example.log\") # this will not print the messages to the console, but save them to a file\n# or\nlog.dump_messages_to_console() # this will print the messages to the console, but not save them to a file\n\n# you can do both if you want!\n\n# if you would like to continue logging after dumping the messages, you can do that too!\n```\n\noutput:\n```shell\n[Buffered Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message\n[Buffered Example] [2023-12-08 08:36:33.155] INFO: This is an info message\n[Buffered Example] [2023-12-08 08:36:33.155] WARN: This is a warning message\n[Buffered Example] [2023-12-08 08:36:33.155] ERROR: This is an error message\n[Buffered Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message\n```\n\nexample.log:\n```shell\n[Buffered Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message\n[Buffered Example] [2023-12-08 08:36:33.155] INFO: This is an info message\n[Buffered Example] [2023-12-08 08:36:33.155] WARN: This is a warning message\n[Buffered Example] [2023-12-08 08:36:33.155] ERROR: This is an error message\n[Buffered Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message\n```\n\n### Amazing! How do I filter messages?\n\n```python\nfrom objlog import LogNode, LogMessage\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"Filter Example\")\n\nlog.log(Debug(\"this is a debug message\"))\nlog.log(Info(\"this is an info message\"))\nlog.log(Warn(\"this is a warning message\"))\nlog.log(Error(\"this is an error message\"))\nlog.log(Fatal(\"this is a fatal message\"))\n\nlog.dump_messages(\"example.log\", elementfilter=[Warn, Error, Fatal]) # this will not print the messages to the console, but save them to a file if they are a warning, error, or fatal\n# the rest of the messages will not be saved to the file\n\n# you can do the same thing with dump_messages_to_console()\n\nlog.dump_messages_to_console(Warn, Error, Fatal)\n\n# you can also filter the log in-place\n\nlog.filter(typefilter=[Warn, Error, Fatal]) # this will remove all messages that are not a warning, error, or fatal from the log's memory\n\n# you can also use the filter method to filter the logfile\n\nlog.filter(typefilter=[Warn, Error, Fatal], filter_logfiles=True) # this will remove all messages that are not a warning, error, or fatal from the log's memory, and overwrite the logfile with the filtered messages\n\n# it even works with custom message types!\n\nclass CustomMessage(LogMessage):\n color = \"\\033[32\" # green\n level = \"CUSTOM\"\n\nlog.log(CustomMessage(\"this is a custom message\"))\nlog.log(CustomMessage(\"this is another custom message\"))\nlog.log(Info(\"this is an info message\"))\n\nlog.dump_messages_to_console(elementfilter=[CustomMessage]) # this will only print the custom messages to the console\n\n# output:\n# [Filter Example] [2023-12-08 08:36:33.155] CUSTOM: This is a custom message\n# [Filter Example] [2023-12-08 08:36:33.155] CUSTOM: This is another custom message\n```\n\n### I want to not have a log file, and then I want to switch to having a log file (and store my old messages in it)!\n\n```python\nfrom objlog import LogNode, LogMessage\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"Switch Example\") # no log file\n\nlog.log(Debug(\"this is a debug message\"))\nlog.log(Info(\"this is an info message\"))\nlog.log(Warn(\"this is a warning message\"))\nlog.log(Error(\"this is an error message\"))\nlog.log(Fatal(\"this is a fatal message\"))\n\nlog.set_output_file(\"example.log\") # now there is a log file, all new messages will be saved to it\n\nlog.log(Debug(\"this is a debug message 2\")) # this message will be saved to the log file\nlog.log(Info(\"this is an info message 2\")) # this message will be saved to the log file\nlog.log(Warn(\"this is a warning message 2\")) # this message will be saved to the log file\nlog.log(Error(\"this is an error message 2\")) # this message will be saved to the log file\nlog.log(Fatal(\"this is a fatal message 2\")) # this message will be saved to the log file\n\n# the messages before the log file was set will not be saved to the log file\n\n# to move the old messages to the log file, you can do this:\n\nlog.set_output_file(\"example2.log\", preserve_old_messages=True) # now the old messages will be saved to the log file, and all new messages will be saved to it as well\n\nlog.log(Debug(\"this is a debug message 3\")) # this message will be saved to the log file\n```\n\nexample.log:\n```shell\n[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2\n[Switch Example] [2023-12-08 08:36:33.155] INFO: This is an info message 2\n[Switch Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 2\n[Switch Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 2\n[Switch Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 2\n```\n\nexample2.log:\n```shell\n[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message\n[Switch Example] [2023-12-08 08:36:33.155] INFO: This is an info message\n[Switch Example] [2023-12-08 08:36:33.155] WARN: This is a warning message\n[Switch Example] [2023-12-08 08:36:33.155] ERROR: This is an error message\n[Switch Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message\n[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2\n[Switch Example] [2023-12-08 08:36:33.155] INFO: This is an info message 2\n[Switch Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 2\n[Switch Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 2\n[Switch Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 2\n[Switch Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 3\n```\n\n### I have a very limited amount of RAM, and I want to limit the amount of messages that are stored in memory!\n\n```python\nfrom objlog import LogNode\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"Limited Example\", max_messages_in_memory=5, log_file=\"limited.log\") # only store 5 messages in memory\n\nlog.log(Debug(\"this is a debug message 1\"))\nlog.log(Info(\"this is an info message 1\"))\nlog.log(Warn(\"this is a warning message 1\"))\nlog.log(Error(\"this is an error message 1\"))\nlog.log(Fatal(\"this is a fatal message 1\"))\n\nlog.log(Debug(\"this is a debug message 2\")) # this message will be stored in memory, and the oldest message will be removed from memory\n```\n\nlimited.log:\n```shell\n[Limited Example] [2023-12-08 08:36:33.155] INFO: This is an info message 1\n[Limited Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 1\n[Limited Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 1\n[Limited Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 1\n[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2\n```\n\n### I have a limited amount of SSD space, and I want to limit the amount of messages that are stored in the log file!\n\n```python\nfrom objlog import LogNode\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"Limited Example\", max_log_messages=5, log_file=\"limited.log\") # only store 5 messages in the log file, but unlimited messages in memory\n\nlog.log(Debug(\"this is a debug message 1\"))\nlog.log(Info(\"this is an info message 1\"))\nlog.log(Warn(\"this is a warning message 1\"))\nlog.log(Error(\"this is an error message 1\"))\nlog.log(Fatal(\"this is a fatal message 1\"))\n\nlog.log(Debug(\"this is a debug message 2\")) # this message will be stored in the log, and the oldest message will be removed from the log\n\nlog.dump_messages_to_console() # this will print all messages in memory to the console (including ones not saved to the log), but not save them to the log file\n\n# to limit both the amount of messages in memory and the amount of messages in the log file, you can do this:\n\nlog = LogNode(name=\"Limited Example\", max_messages_in_memory=5, max_log_messages=5, log_file=\"limited.log\") # only store 5 messages in the log file, and only store 5 messages in memory\n```\n\noutput:\n```shell\n[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 1\n[Limited Example] [2023-12-08 08:36:33.155] INFO: This is an info message 1\n[Limited Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 1\n[Limited Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 1\n[Limited Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 1\n[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2\n```\n\nlimited.log:\n```shell\n[Limited Example] [2023-12-08 08:36:33.155] INFO: This is an info message 1\n[Limited Example] [2023-12-08 08:36:33.155] WARN: This is a warning message 1\n[Limited Example] [2023-12-08 08:36:33.155] ERROR: This is an error message 1\n[Limited Example] [2023-12-08 08:36:33.155] FATAL: This is a fatal message 1\n[Limited Example] [2023-12-08 08:36:33.155] DEBUG: This is a debug message 2\n```\n\n### I want to log messages, but I don't want to print them to the console or a log file, and I don't want to store them in memory!\n\n1, that's useless why? and 2, you can do that!\n\n```python\nfrom objlog import LogNode\nfrom objlog.LogMessages import Debug, Info, Warn, Error, Fatal\n\nlog = LogNode(name=\"Buffered Example\", max_messages_in_memory=0)\n\nlog.log(Debug(\"this is a debug message\"))\nlog.log(Info(\"this is an info message\"))\nlog.log(Warn(\"this is a warning message\"))\nlog.log(Error(\"this is an error message\"))\nlog.log(Fatal(\"this is a fatal message\"))\n```\n\noutput:\n```shell\n```\n\n## I want more examples!\n\ncheck out the [examples](examples) folder within this project, plenty of examples there!\n\n## I want to use this in a project!\nFeel free to! This project is licensed under the Zlib license, so you can use it in any project, commercial or not, as long as you give credit to the original author (me) and don't claim it as your own.\n\n## I want to contribute!\nFeel free to!\nFork the repo, make your changes, and submit a pull request!\nI'll review it, and if it's good, I'll merge it!\n\n(for more information, see [CONTRIBUTING](CONTRIBUTING.md))\n\n## I want to report a bug or request a feature!\nFeel free to! Just open an issue, and I'll look into it!\n\n## I found a security vulnerability!\nPlease don't open an issue for that! Instead, either make a pull request with the fix, or submit a vulnerability report! please read [SECURITY](SECURITY.md) for more information.\n",
"bugtrack_url": null,
"license": "Zlib",
"summary": "Logging, Objectified.",
"version": "2.1.5",
"project_urls": {
"Homepage": "https://github.com/Kokonico/ObjLog",
"Repository": "https://github.com/Kokonico/ObjLog"
},
"split_keywords": [
"logging",
" object",
" objectified",
" log",
" logger",
" loggers",
" oop",
" python",
" python3",
" python3.10",
" python3.11",
" python3.12"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dbb84fb6684e377576cc045c3570b2a5931f5946f37d3b006b4fa9150e08d737",
"md5": "8bd832b851350d94008fd8f009f4ee54",
"sha256": "77237e278d3956a23f4f2ab99860af7e52eed2ccaa1a070e349260cc196d0776"
},
"downloads": -1,
"filename": "objlog-2.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8bd832b851350d94008fd8f009f4ee54",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 10983,
"upload_time": "2024-07-20T14:47:40",
"upload_time_iso_8601": "2024-07-20T14:47:40.707295Z",
"url": "https://files.pythonhosted.org/packages/db/b8/4fb6684e377576cc045c3570b2a5931f5946f37d3b006b4fa9150e08d737/objlog-2.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4570367cc336e7f96f98b22704c788a55271293140cbd60c96a1bd4a8a239b09",
"md5": "2d5294d98df791558aff4eab6881371c",
"sha256": "7d884a284b83a9353cb4f94bff1cd37e683a7926b49e26dabd0d10db33be309c"
},
"downloads": -1,
"filename": "objlog-2.1.5.tar.gz",
"has_sig": false,
"md5_digest": "2d5294d98df791558aff4eab6881371c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 11105,
"upload_time": "2024-07-20T14:47:42",
"upload_time_iso_8601": "2024-07-20T14:47:42.160679Z",
"url": "https://files.pythonhosted.org/packages/45/70/367cc336e7f96f98b22704c788a55271293140cbd60c96a1bd4a8a239b09/objlog-2.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-20 14:47:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Kokonico",
"github_project": "ObjLog",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "objlog"
}