Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

aymericderbois/mattermost-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kezako ?

This library allow you to use mattermost has an handler for your log system.

Installation

pip install mattermost_handler

Configuration

Django

For WARNING message

If you want to log on mattermost, you have to add an handler. For example, to send warning message

LOGGING = {
    'version': 1,
    'formatters': {
        'simple': {
            'format': '[%(asctime)s][%(levelname)s] %(message)s'
        },
    },
    'handlers': {
        'mattermost': {
            'level': 'WARTNING',
            'class': 'mattermost_handler.MattermostIncomeWebhookHandler',
            'formatter': 'simple',
            'url': 'https://mattermost.example.com/hooks/4m5sdub8sfg5s488uyt1Q97ei39fa'
        }
    },
    'loggers': {
        'django': {
            'handlers': ['mattermost'],
            'propagate': True,
            'level': 'INFO'
        }
    }
}

For specific message

You also can create a specific logger for mattermost

LOGGING = {
    'version': 1,
    'formatters': {
        'simple': {
            'format': '[%(asctime)s][%(levelname)s] %(message)s'
        },
    },
    'handlers': {
        'mattermost': {
            'level': 'INFO',
            'class': 'mattermost_handler.MattermostIncomeWebhookHandler',
            'formatter': 'simple',
            'url': 'https://mattermost.example.com/hooks/4m5sdub8sfg5s488uyt1Q97ei39fa'
        }
    },
    'loggers': {
        'mattermost': {
            'handlers': ['mattermost'],
            'propagate': True,
            'level': 'INFO'
        }
    }
}

And in your code

logger = logging.getLogger('mattermost')

logger.info('this message will be sent to mattermost')

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages