version: 1
disable_existing_loggers: False

# root:
#     level: DEBUG
#     handlers:
#         - debug_console
#         - debug_file

loggers:

    # user logger
    usr:
        # level: NOTSET
        level: DEBUG
        handlers:
            - usr_debug_console
            - usr_debug_file
            - usr_info_file
            - usr_warning_file
            - usr_error_file
            - usr_critical_file

handlers:

    usr_debug_console:
        class: 'logging.StreamHandler'
        level: DEBUG
        formatter: usr_debug
        stream: 'ext://sys.stderr'

#   person_info_rotating_file_handler:
#       class: 'logging.handlers.RotatingFileHandler'
#       level: INFO
#       formatter: info
#       filename: 'info.rotating.log'
#       mode: 'a'
#       maxBytes: 1048576  # 1MB
#       backupCount: 10
#       encoding: utf8

    usr_debug_file:
        class: 'logging.FileHandler'
        level: DEBUG
        formatter: usr_debug
        filename: '{{dir_run_debs}}/debs_{{ts}}_{{pid}}.log'
        mode: 'a'
        delay: true

    usr_info_file:
        class: 'logging.FileHandler'
        level: INFO
        formatter: usr_info
        filename: '{{dir_run_infs}}/infs_{{ts}}_{{pid}}.log'
        mode: 'a'
        delay: true

    usr_warning_file:
        class: 'logging.FileHandler'
        level: ERROR
        formatter: usr_warning
        filename: '{{dir_run_wrns}}/wrns_{{ts}}_{{pid}}.log'
        mode: 'a'
        delay: true

    usr_error_file:
        class: 'logging.FileHandler'
        level: ERROR
        formatter: usr_error
        filename: '{{dir_run_errs}}/errs_{{ts}}_{{pid}}.log'
        mode: 'a'
        delay: true

    usr_critical_file:
        class: 'logging.FileHandler'
        level: ERROR
        formatter: usr_error
        filename: '{{dir_run_crts}}/crts_{{ts}}_{{pid}}.log'
        mode: 'a'
        delay: true

    usr_critical_mail:
        class: 'logging.handlers.SMTPHandler'
        level: CRITICAL
        formatter: usr_critical
        mailhost : localhost
        fromaddr: 'monitoring@domain.com'
        toaddrs:
            - 'dev@domain.com'
            - 'qa@domain.com'
        subject: 'Critical error with application name'


formatters:

    usr_debs:
        format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
        datefmt: '%Y-%m-%d %H:%M:%S'
    usr_infs:
        format: '%(asctime)s-%(levelname)s-%(name)s::%(module)s|%(lineno)s:: %(message)s'
    usr_wrns:
        format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
        datefmt: '%Y-%m-%d %H:%M:%S'
    usr_errs:
        format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
        datefmt: '%Y-%m-%d %H:%M:%S'
    usr_critical:
        format: '%(asctime)-15s %(levelname)s-%(name)s-%(process)d::%(module)s.%(funcName)s|%(lineno)s:: %(message)s'
        datefmt: '%Y-%m-%d %H:%M:%S'
