Examples#
The runnable demo script in the repository lives at examples/usage.py.
Console And File Output#
import tuning
tuning.basicConfig(
filename="app.log",
console=True,
level="INFO",
show_time=True,
datefmt=tuning.ISO_FORMAT,
)
logger = tuning.getLogger(__name__)
logger.info("application started")
Rotating File Logs#
import tuning
tuning.basicConfig(
filename="app.log",
level="INFO",
max_bytes="10 MB",
backup_count=5,
)
logger = tuning.getLogger(__name__)
logger.info("rotating file output")
Boxed Console Records#
import tuning
tuning.basicConfig(level="INFO", boxes=True, show_icon=True)
logger = tuning.getLogger(__name__)
logger.success("boxed output")
Styled Prompt#
import tuning
logger = tuning.getLogger(__name__)
name = logger.prompt("Your name?")
logger.info("hello %s", name)
YAML Configuration#
Export a full starter config:
import tuning
tuning.export("tuning.yml")
Use a small override file:
handlers:
console:
level: DEBUG
show_time: true
show_path: true
show_icon: true
root:
level: DEBUG
Load YAML configuration:
import tuning
tuning.basicConfigFromYaml("tuning.yml", force=True)
logger = tuning.getLogger(__name__)
logger.info("configured from YAML")