Stream Sage Logger for Python
Project description
STREAM SAGE PYTHON LOGGER
Log format
[<Date> <Time>][<logLevel>][<context>][<file>:<line>][<LoggerOptionalParams>] <message>
Date format: YYYY-MM-DD
Time format: HH:mm:ss
Logger output
[2022-04-15 12:06:34][info][Sample App][samle_file.py:1] Sample LOG message
[2022-04-15 03:06:00][info][Sample App][samle_file.py:1][messageId:some-message-id][domain:message-domain] Sample LOG message with additional params
[2022-04-15 12:06:34][error][Sample App][samle_file.py:1][customer:customer] Sample ERROR message with additional params
[2022-04-15 21:43:36][debug][Sample App][samle_file.py:1][debugLevel:5] Sample Debug message in debug level 5
[2022-04-15 10:20:28][debug][Sample App][samle_file.py:1][debugLevel:2] Sample Debug message in debug level 2
Installation
Add streamsage-python-logger==0.0.17 to requirements.txt or install via pip:
pip install streamsage-python-logger==0.0.17
Environments
| Variable | Description | Default | Supported |
|---|---|---|---|
LOG_SDK_NO_COLOR |
Set to any value to disable logs colorizing | - | - |
LOG_SDK_TRANSPORTS |
Comma separated list of log transporters that will be used by app. | - | fluent |
LOG_SDK_SERVICE_NAME |
Service name that will be included in message payload. | - | - |
Logger options:
Required:
context- The context of logger instance.
Optional:
level- Enable logger via passing a log level:fatal,error,warn,info,debug,traceorfalseif it should be disabled. Default:infoThen, you can use following methodslog(),fatal(),error(),warn(),info(),debug(),trace():log()- displays message in given log level.fatal()- displays message infatallog level.error()- displays message inerrorlog level.warn()- displays message inwarnlog level.info()- displays message ininfolog level.debug()- displays message indebuglog level.trace()- displays message intracelog level.
Available transports
Below has been describe all currently supported transport by the Logger.
Console
Notice: Console transport is always enabled.
| Variable | Description | Default | Supported |
|---|---|---|---|
LOG_SDK_TRANSPORT_CONSOLE_LEVEL |
Logging level to console | info |
fatal, error, warn, info, debug, trace |
Fluent
| Variable | Description | Default | Supported |
|---|---|---|---|
LOG_SDK_TRANSPORT_FLUENT_LEVEL |
Logging level to FluentD | info |
fatal, error, warn, info, debug, trace |
LOG_SDK_TRANSPORT_FLUENT_URL |
URL of the FluentD server | - | - |
LOG_SDK_TRANSPORT_FLUENT_TIMEOUT |
Timeout for response from the FluentD server. | 3000 |
- |
Logger sample usage
Logger can be initialized by get_logger() method:
from streamsage_python_logger.streamsage_logger import get_logger
logger = get_logger("SomeApp")
for implementing logger with other libraries use LoggerConfig class with logging dictConfig e.g. on FastApi and uvicorn server:
import uvicorn
from fastapi import FastAPI
from logging.config import dictConfig
from streamsage_python_logger.streamsage_logger import LoggerConfig
app = FastAPI()
if __name__ == "__main__":
uvicorn.run(app, host='0.0.0.0', port=8080,
access_log=False,
log_config=dictConfig(LoggerConfig(context='SomeApp').dict()),
log_level='info')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamsage_python_logger-0.0.18.tar.gz.
File metadata
- Download URL: streamsage_python_logger-0.0.18.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cd917c92841054d14d901724abb7c4461f8298f6836a26161086b222b48d4f9
|
|
| MD5 |
b790882a8faac216aea3ae15909bab36
|
|
| BLAKE2b-256 |
8d76fbf416af683b0c28d3c5d9110da394f60b840ccf9b828271ca69cac7c606
|
File details
Details for the file streamsage_python_logger-0.0.18-py3-none-any.whl.
File metadata
- Download URL: streamsage_python_logger-0.0.18-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
734478c96bac3984cdc15ce657066a283c68bf2fd746370b1972c1485d23ba54
|
|
| MD5 |
cb419a50124a03890f541b57e5ac0df2
|
|
| BLAKE2b-256 |
3ed83637b43e0e9b74bfa96a2ee0e9e2da1b0fa8befe44e613cfb940ca080f4d
|