Skip to main content

What does this package do

Tail log files on your server and report by email if error occurs.

By default, the regex pattern was set for default uwsgi logs.

Install

pip install tail_uwsgi_log

Usage

tail_uwsgi_log -c your_config_filepath.ini

Configs

The config file provides infomations needed to send an email and log-files to tail.

For example:

; section name startswith 'log' would be interpreted as logfile config
[log-myapp1]

; log file path
filepath = your_log_filepath

; wait_time for tail command, the thread will sleep and wait
; the wait_time should be small if the server is busy and generates log lines quickly
wait_time = 0.5

; the regex pattern to read the log line, the line doesn't match this regex will be recorded as innormal
pattern = 

; mail settings
mail_recipients = example1@example.com, example2@example.com

mail_host = smtp.qq.com
mail_port = 465
mail_sender = your_email_address
mail_password = your_password

To tail several log files at the same time, we could set several sections on config files, the section name should start with 'log'.

For mail settings, we could use a section named 'mail' to set default value. The default value will be used if not set in log section.

For example:

[log-myapp1]
filepath = your_log_filepath1
wait_time = 0.5
pattern = 
mail_recipients = example1@example.com, example2@example.com

[log-myapp2]
filepath = your_log_filepath2
wait_time = 1
pattern = 
mail_recipients = example3@example.com, example4@example.com

[mail]
mail_host = smtp.qq.com
mail_port = 465
mail_sender = your_email_address
mail_password = your_password

The default regex pattern to match the logline was for default uwsgi logs, which is:

pattern = r'''\]\ (?P<ip>.*?)\ (.*)\ {.*?}\ \[(?P<datetime>.*?)\]\ (?P<request_method>POST|GET|DELETE|PUT|PATCH)\s
            (?P<request_uri>[^ ]*?)\ =>\ generated\ (?:.*?)\ in\ (?P<resp_msecs>\d+)\ msecs\s
            \(HTTP/[\d.]+\ (?P<resp_status>\d+)\)'''

The 'resp_status' in the pattern is important, which will be used as a signal.

When the resp_status is 500, an email will be sent with all innormal log lines recorded before.

Release files for tail-uwsgi-log 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tail-uwsgi-log 0.0.4
File Size Uploaded
tail_uwsgi_log-0.0.4.tar.gz 5.1 kB Details

Release files / tail_uwsgi_log-0.0.4.tar.gz

Download URL tail_uwsgi_log-0.0.4.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d5e3036d20ef560b25a3130445f280fcbd480f1e01eaf9bc199b181f080657bb
BLAKE2b-256 checksum
How to use checksums
70f2728b24666ace60607de64390a04d892ed0702750fc6fdb2961bce51404be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page