Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A Simple and Human Friendly Slack Client for Logging.

Project Description

slackpy

A Simple and Human Friendly Slack Client for Logging.

Use Case

Install

pip install slackpy

Dependencies

  • requests

Sample Code

import slackpy

INCOMING_WEB_HOOK = 'your_web_hook_url'
CHANNEL = '#general'
USER_NAME = 'Logger'
ICON_URL = 'http://lorempixel.com/48/48'

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

# You can set a log level. The 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)

# Simple Usage
logging.info('INFO Message')

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

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

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

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

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

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

# Title Link (New v2.1.0)
logging.info(message='INFO Message', title='slackpy Repository here',
             title_link='https://github.com/iktakahiro/slackpy')
Method LogLevel Color
debug() DEBUG (10) #03A9F4 (Light Blue)
info() INFO (20) good (green)
warn() WARNING (30) warning (orange)
error() ERROR (40) danger (red)

The definition of the log level is based on the 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 'INFO Message Title' -m 'INFO Message' -l 20

For AWS Lamdba

# First, pip install to top of project directory.
pip install slackpy -t .

# Second, archive your source code and dependency packages.
zip -r src.zip lambda_function.py slackpy enum requests

# Finally, upload src.zip

About Versioning

slackpy is following Semantic Versioning 2.0.0.

Release History

Release History

This version
History Node

2.2.2

History Node

2.2.1

History Node

2.1.3

History Node

2.1.1

History Node

1.4.6

History Node

1.4.5

History Node

1.4.4

History Node

1.4.2

History Node

1.4.1

History Node

1.4.0

History Node

1.3.1

History Node

1.3.0

History Node

1.2.0

History Node

1.1.4

History Node

1.1.3

History Node

1.1.2

History Node

1.1.1

History Node

1.1.0

History Node

1.0.0

History Node

0.3.1

History Node

0.3.0

History Node

0.2.1

History Node

0.2.0

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
slackpy-2.2.2.tar.gz (4.9 kB) Copy SHA256 Checksum SHA256 Source Dec 10, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting