cpython/Modules/syslogmodule.c

/***********************************************************
Copyright 1994 by Lance Ellinghouse,
Cathedral City, California Republic, United States of America.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Lance Ellinghouse
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.

LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL,
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

******************************************************************/

/******************************************************************

Revision history:

2010/04/20 (Sean Reifschneider)
  - Use basename(sys.argv[0]) for the default "ident".
  - Arguments to openlog() are now keyword args and are all optional.
  - syslog() calls openlog() if it hasn't already been called.

1998/04/28 (Sean Reifschneider)
  - When facility not specified to syslog() method, use default from openlog()
    (This is how it was claimed to work in the documentation)
  - Potential resource leak of o_ident, now cleaned up in closelog()
  - Minor comment accuracy fix.

95/06/29 (Steve Clift)
  - Changed arg parsing to use PyArg_ParseTuple.
  - Added PyErr_Clear() call(s) where needed.
  - Fix core dumps if user message contains format specifiers.
  - Change openlog arg defaults to match normal syslog behavior.
  - Plug memory leak in openlog().
  - Fix setlogmask() to return previous mask value.

******************************************************************/

/* syslog module */

// clinic/syslogmodule.c.h uses internal pycore_modsupport.h API
#ifndef Py_BUILD_CORE_BUILTIN
#define Py_BUILD_CORE_MODULE
#endif

#include "Python.h"
#include "osdefs.h"               // SEP

#include <syslog.h>

/*[clinic input]
module syslog
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=478f4ac94a1d4cae]*/

#include "clinic/syslogmodule.c.h"

/*  only one instance, only one syslog, so globals should be ok,
 *  these fields are writable from the main interpreter only. */
static PyObject *S_ident_o =;  // identifier, held by openlog()
static char S_log_open =;

static inline int
is_main_interpreter(void)
{}

static PyObject *
syslog_get_argv(void)
{}


/*[clinic input]
@critical_section
syslog.openlog

    ident: unicode = NULL
    logoption as logopt: long = 0
    facility: long(c_default="LOG_USER") = LOG_USER

Set logging options of subsequent syslog() calls.
[clinic start generated code]*/

static PyObject *
syslog_openlog_impl(PyObject *module, PyObject *ident, long logopt,
                    long facility)
/*[clinic end generated code: output=5476c12829b6eb75 input=ee700b8786f81c23]*/
{}



/*[clinic input]
@critical_section
syslog.syslog

    [
    priority: int(c_default="LOG_INFO") = LOG_INFO
    ]

    message: str

    /

Send the string message to the system logger.
[clinic start generated code]*/

static PyObject *
syslog_syslog_impl(PyObject *module, int group_left_1, int priority,
                   const char *message)
/*[clinic end generated code: output=c3dbc73445a0e078 input=6588ddb0b113af8e]*/
{}


/*[clinic input]
@critical_section
syslog.closelog

Reset the syslog module values and call the system library closelog().
[clinic start generated code]*/

static PyObject *
syslog_closelog_impl(PyObject *module)
/*[clinic end generated code: output=97890a80a24b1b84 input=167f489868bd5a72]*/
{}

/*[clinic input]
syslog.setlogmask -> long

    maskpri: long
    /

Set the priority mask to maskpri and return the previous mask value.
[clinic start generated code]*/

static long
syslog_setlogmask_impl(PyObject *module, long maskpri)
/*[clinic end generated code: output=d6ed163917b434bf input=adff2c2b76c7629c]*/
{}

/*[clinic input]
syslog.LOG_MASK -> long

    pri: long
    /

Calculates the mask for the individual priority pri.
[clinic start generated code]*/

static long
syslog_LOG_MASK_impl(PyObject *module, long pri)
/*[clinic end generated code: output=c4a5bbfcc74c7c94 input=534829cb7fb5f7d2]*/
{}

/*[clinic input]
syslog.LOG_UPTO -> long

    pri: long
    /

Calculates the mask for all priorities up to and including pri.
[clinic start generated code]*/

static long
syslog_LOG_UPTO_impl(PyObject *module, long pri)
/*[clinic end generated code: output=9eab083c90601d7e input=5e906d6c406b7458]*/
{}

/* List of functions defined in the module */

static PyMethodDef syslog_methods[] =;


static int
syslog_exec(PyObject *module)
{}

static PyModuleDef_Slot syslog_slots[] =;

/* Initialization function for the module */

static struct PyModuleDef syslogmodule =;

PyMODINIT_FUNC
PyInit_syslog(void)
{}