Table of Contents

Exemplo de Interface Syslog (biblioteca) Python

36.15. syslog — Unix syslog library routines

Este módulo prove uma interface para a rotinas UNIX syslog.

Este modulo cobre as rotinas do sistema syslog. A pure Python library that can speak to a syslog server is available in the logging.handlers module as SysLogHandler.

The module defines the following functions:

The module defines the following constants:

Simple example

May 11 10:40:48 scrooge disk-health-nurse[26783]: [ID 702911 user.error] m:SY-mon-full-500 c:H : partition health   measures for /var did not suffice - still using 96% of partition space

Dividido em colunas:

A simple set of examples:

import syslog

syslog.syslog('Processing started')
if error:
    syslog.syslog(syslog.LOG_ERR, 'Processing started')

An example of setting some log options, these would include the process ID in logged messages, and write the messages to the destination facility used for mail logging:

syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL)
syslog.syslog('E-mail processing initiated...')