Skip to content

Instantly share code, notes, and snippets.

logger.info("Hello World")
logger.info("Request from {} handled in {:.3f} ms", socket.gethostname(), 11)
logger.info("Request from {} handled in {:.3f} ms", "127.0.0.1", 33.1)
logger.info("My favorite drinks are {}, {}, {}, {}", "milk", "wine", "tea", "beer")
logger.debug("this is a {} message", logging.getLevelName(logging.DEBUG))
logger.info("this is a {} message", logging.getLevelName(logging.INFO))
logger.warning("this is a {} message", logging.getLevelName(logging.WARNING))
logger.error("this is a {} message", logging.getLevelName(logging.ERROR))
logger.critical("this is a {} message", logging.getLevelName(logging.CRITICAL))
logger.info("Does old-style formatting also work? %s it is, but no colors (yet)", True)
[DATABASE]
env_name = staging
endpoint = staging:3001
[LOG]
console_enabled = true
console_level = INFO
file_enabled = true
file_rotation_size_mb = 10
file_backup_count = 1000
[DATABASE]
endpoint =
env_name = default
@davidohana
davidohana / layconf_example.py
Last active May 20, 2020 15:37
LayConf Example usage
from layconf import LayConf
# the default config file is cfg/default.ini unless specified other
# custom_config_file_path is an optional layer
# env_prefix is empty by default, which means that environment variable names will be
# mapped to {section}_{option}
LayConf.init_config(custom_config_file_path="cfg/staging.ini", env_prefix="example")
print("env_name:", LayConf.get("DATABASE", "env_name"))
print("console_enabled:", LayConf.getboolean("LOG", "console_enabled"))