Skip to content

Instantly share code, notes, and snippets.

View ckesanapalli's full-sized avatar

Chaitanya Kesanapalli ckesanapalli

View GitHub Profile
@ckesanapalli
ckesanapalli / log_conf.py
Last active March 28, 2022 14:13
Logging configuration code with wrapper that log entry, exit and runtime of functions with a decorator using logging module
import logging
from datetime import datetime
from pathlib import Path
import functools
from pprint import pformat
def get_func_name(func):
"""Return the name of the given function including module name"""
if func.__class__.__module__ == "builtins":
mod_name = func.__module__ if hasattr(func, '__module__') and \
@ckesanapalli
ckesanapalli / main.py
Last active March 19, 2022 23:15
Logging entry, exit and runtime of functions with a decorator using loguru module
import time
from loguru import logger
from more_loguru import logger_wraps
logger.add('test.log', mode='w')
@logger_wraps(debug_io=True)
def my_func(a, b, c=1, d="Text"):
"""A test function"""
time.sleep(1)