Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Improved version of the standard logger.
TRACE
level.ColorizedFormatter
.This package patching the standard logging
library.
Thus, after import, all improvements will be available inside the logging
module.
But for better typing, I prefer to use betterlogging
everywhere.
Python 3.7 and above. No additional dependencies.
pip install betterlogging
import betterlogging as logging
logging.basic_colorized_config(level=logging.INFO)
logger = logging.getLogger('test')
logger.trace("some trace message")
logger.debug("some debug message")
logger.info("some info message")
logger.warning("some warning message")
logger.error("some error message")
logger.critical("some critical message")
import betterlogging as logging
# You can use shortcut:
logger = logging.get_colorized_logger(name="test")
# Or, if you want to configure formatter:
handler = logging.StreamHandler()
handler.setFormatter(logging.ColorizedFormatter(hide_lib_diagnose=False))
logger.addHandler(handler)
logger.setLevel(logging.TRACE)
logger.trace("some trace message")
logger.debug("some debug message")
logger.info("some info message")
logger.warning("some warning message")
logger.error("some error message")
logger.critical("some critical message")
def div(x: int, y: int) -> float:
return x / y
try:
div(1, 0)
except:
logger.exception("Some exception")
uvicorn
{
"version": 1,
"disable_existing_loggers": false,
"formatters": {
"default": {
"()": "betterlogging.ColorizedFormatter"
},
"access": {
"()": "betterlogging.ColorizedFormatter",
"fmt": "%(c_fg_green)s%(asctime)s %(c_color)s%(levelname)-8s%(c_reset)s %(c_fg_cyan)s[%(name)s] %(c_reset)s%(message)s"
}
},
"handlers": {
"default": {
"formatter": "default",
"class": "logging.StreamHandler"
},
"access": {
"formatter": "access",
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout"
}
},
"loggers": {
"": {
"handlers": [
"default"
],
"level": "DEBUG"
},
"uvicorn.error": {
"level": "INFO"
},
"uvicorn.access": {
"handlers": [
"access"
],
"level": "INFO",
"propagate": false
}
}
}
uvicorn application:app --debug --reload --log-config ./logging.json
FAQs
My logging improvement
We found that betterlogging demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.