python logging simplified

Logging is great in Python, but it is a Pain to setup.

When you want at times is something Quick and Simple

Welcome to daiquiri

Install

100% easy

pip install daiquiri

Example usage

THis takes care of 99% of my use-cases.

import daiquiri
import logging


class Bob(object):
    def __init__(self):
        self.logger = daiquiri.getLogger(str(type(self)))
        self.logger.info("Hi from "+str(type(self)))
        print("Bob Initialized")


daiquiri.setup(outputs=(
    daiquiri.output.Syslog(),
    daiquiri.output.STDERR,
    daiquiri.output.File(directory=".")),
    level=logging.DEBUG)
logger = daiquiri.getLogger()


logger.error("Error")
logger.debug("Debug")
logger.info("Hi")
logger.critical("Critical")
logger.warning("Warning")
#psk=Psk32()
logger.info("Closing")
b=Bob()

print("Done")

When you run it.... on a Teminal the output is coloured !! Ooooooo Nice

2018-03-09 10:45:01,576 [15287] ERROR    root: Error
2018-03-09 10:45:01,577 [15287] DEBUG    root: Debug
2018-03-09 10:45:01,577 [15287] INFO     root: Hi
2018-03-09 10:45:01,578 [15287] CRITICAL root: Critical
2018-03-09 10:45:01,578 [15287] WARNING  root: Warning
2018-03-09 10:45:01,578 [15287] INFO     root: Closing
2018-03-09 10:45:01,578 [15287] INFO     <class '__main__.Bob'>: Hi from <class '__main__.Bob'>

Log Rotation

For some projects with Large data output, you should use Log Rotation

```python import datetime import logging

import daiquiri

daiquiri.setup( level=logging.DEBUG, outputs=( daiquiri.output.File('errors.log', level=logging.ERROR), daiquiri.output.TimedRotatingFile( 'everything.log', level=logging.DEBUG, interval=datetime.timedelta(hours=1)) ) )

logger = daiquiri.getLogger(name)

logger.info('only to rotating file logger') logger.error('both log files, including errors only')```