Skip to main content

Simple Slack client library

Project description

Build Status

slackpy

slackpy is Slack client library for specific logging.

Install

pip install slackpy

Dependencies

  • requests<3,>=2.8.0

Sample Code

import slackpy

INCOMING_WEB_HOOK = 'your_web_hook_url'
CHANNEL = '#general'
USER_NAME = 'Logger'

# Create a new instance.
logging = slackpy.SlackLogger(INCOMING_WEB_HOOK, CHANNEL, USER_NAME)

# You can set log level. Default level is INFO.
logging.set_log_level(slackpy.LogLv.DEBUG) # Or logging.set_log_level(10)

## Minimum Parameter
## logging = slackpy.SlackLogger(INCOMING_WEB_HOOK)

LogLevel's only required parameter is "message", all others are optional.

# LogLevel: DEBUG
logging.info(message='DEBUG Message', title='INFO Title', fallback='', fields='')

# LogLevel: INFO
logging.info(message='INFO Message', title='INFO Title', fallback='', fields='')

# LogLevel: WARN
logging.warn(message='WARN Message', title='INFO Title', fallback='', fields='')

# LogLevel: ERROR
logging.error(message='ERROR Message', title='INFO Title', fallback='', fields='')

# LogLevel: CUSTOM
logging.message(message='CUSTOM Message', title='CUSTOM Title', fallback='CUSTOM Fallback', color='good',
                fields=[{"title": "CUSTOM", "value": "test", "short": "true"}],
                log_level=40)

Correspondence table

Method

LogLevel

Color

debug()

DEBUG (10)

#03A9F4 (Light Blue)

info()

INFO (20)

good (green)

warn()

WARNING (30)

warning (orange)

error()

ERROR (40)

danger (red)

LogLevel based on logging standard library (https://docs.python.org/3.4/library/logging.html#levels)

Command line

export SLACK_INCOMING_WEB_HOOK='your_web_hook_url'

# LogLevel: DEBUG
slackpy -c '#your_channel' -m 'DEBUG Message' -l 10

# LogLevel: INFO
slackpy -c '#your_channel' -m 'INFO Message' -l 20

# LogLevel: WARN
slackpy -c '#your_channel' -m 'WARN Message' -l 30

# LogLevel: ERROR
slackpy -c '#your_channel' -m 'ERROR Message' -l 40

# LogLevel: DEBUG (without specifying #channel)
slackpy -m 'DEBUG Message' -l 10

# LogLevel: INFO (with Message Title)
slackpy -c '#your_channel' -t 'DEBUG: Message Title' -m 'INFO Message' -l 20

About Versioning

slackpy is following Semantic Versioning 2.0.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slackpy-1.3.1.tar.gz (4.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page