python logger libary
Project description
scratch-pad-py
Projects that have been ported below.
https://github.com/polonaiz/scratch-pad
mind blowing python toolset. why not pr?
Spec
Loggers: composite, console, file, fluent, jandi, line, memory, null, scribe, telegram
Logger interface
from .logger_interface import LoggerInterface
class Logger(LoggerInterface):
logger: LoggerInterface = None
@classmethod
def setLogger(cls, logger: LoggerInterface):
cls.logger = logger
@classmethod
def getLogger(cls) -> LoggerInterface:
return cls.logger
@classmethod
def info(cls, message: dict, option: dict = {}):
cls.logger.info(message, option)
@classmethod
def notice(cls, message: dict, option: dict = {}):
cls.logger.notice(message, option)
@classmethod
def warning(cls, message: dict, option: dict = {}):
cls.logger.warning(message, option)
@classmethod
def error(cls, message: dict, option: dict = {}):
cls.logger.error(message, option)
@classmethod
def critical(cls, message: dict, option: dict = {}):
cls.logger.critical(message, option)
Usage
FileLogger
filePath = "/tmp/scratch-pad-python.log"
logger = FileLogger(
config={
"filePath": filePath,
"truncate": True
}
)
message = {
"type": "file",
"message": "hello world"
}
logger.info(message)
CompositeLogger
consoleLogger = ConsoleLogger(
config={
"appendNewLine": 1
}
)
memoryLogger = MemoryLogger()
memoryLoggerCompositeFilter = CompositeLogger.getSelectorLevel(["info", "error"])
message = {
"type": "composite",
"message": "hello world"
}
compositLogger = CompositeLogger(
config={
"defaults": {
"datetime": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"program": "scratch-pad-python",
},
"loggerFilterPairs": [
{
"logger": consoleLogger,
"filter": None
},
{
"logger": memoryLogger,
"filter": memoryLoggerCompositeFilter
}
],
}
)
compositLogger.info(message)
JandiLogger
url = "url"
logger = JandiLogger(
url=url
)
message = {
"type": "jandi",
"message": "hello world"
}
logger.info(message)
TelegramLogger
token = "telegram"
chat_id = 1234
message = {
"type": "telegram",
"message": "hello world",
}
logger = TelegramLogger(
chat_id=chat_id,
token=token,
)
logger.info(message)
FluentLogger
logger = FluentLogger()
message = {
"type": "fluent",
"message": "hello world"
}
logger.info(message)
stuff)
scribe-docker for ScribeLogger : https://hub.docker.com/r/polonaiz/facebook-scribe
fluent-docker for FluentLogger : https://github.com/chirichidi/fluent-docker/tree/main
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
scratchpad-py-0.0.3.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file scratchpad-py-0.0.3.tar.gz
.
File metadata
- Download URL: scratchpad-py-0.0.3.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed2bc9fb274bf5e4a360dc3c1ffa33cc1ce944137408ffbf0d83b64c5c517473 |
|
MD5 | 9be0a26b89097e2db63355a605017ab2 |
|
BLAKE2b-256 | 454b8b9b8b8e83c1b507a0c3c96909e36de9fb64d38022b456ed75044a18e1cf |
File details
Details for the file scratchpad_py-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: scratchpad_py-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c5066be95d3778c1aaa510fe284cbd3dc98072ba7c7617b16acfcc2098cc656 |
|
MD5 | dfd5313d283b4159ab630d7df35ceb9c |
|
BLAKE2b-256 | 5320e1efb0a3f13e8bdddd5c6c077b89e11567251617fa1302d5681a458b19e1 |