-
Notifications
You must be signed in to change notification settings - Fork 1
/
python_logging.c
83 lines (66 loc) · 1.92 KB
/
python_logging.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "python_logging.h"
#include "logger.h"
USING_LOGGER(PythonManager)
static PyObject* log_info(PyObject *self, PyObject *args)
{
int module_id;
char* message;
if(!PyArg_ParseTuple(args, "is:log_error", &module_id, &message))
{
LOG_ERROR(PythonManager, "Argument parse error");
Py_RETURN_NONE;
}
LOG_INFO(module_id, message);
Py_RETURN_NONE;
}
static PyObject* log_error(PyObject *self, PyObject *args)
{
int module_id;
char* message;
if(!PyArg_ParseTuple(args, "is:log_error", &module_id, &message))
{
LOG_ERROR(PythonManager, "Argument parse error");
Py_RETURN_NONE;
}
LOG_ERROR(module_id, message);
Py_RETURN_NONE;
}
static PyObject* log_debug(PyObject *self, PyObject *args)
{
int module_id;
char* message;
if(!PyArg_ParseTuple(args, "is:log_error", &module_id, &message))
{
LOG_ERROR(PythonManager, "Argument parse error");
Py_RETURN_NONE;
}
LOG_DEBUG(module_id, message);
Py_RETURN_NONE;
}
static PyObject* log_advanced(PyObject *self, PyObject *args)
{
int module_id;
char* message;
if(!PyArg_ParseTuple(args, "is:log_error", &module_id, &message))
{
LOG_ERROR(PythonManager, "Argument parse error");
Py_RETURN_NONE;
}
LOG_ADVANCED(module_id, message);
Py_RETURN_NONE;
}
static PyMethodDef LogMethods[] = {
{"log_info", log_info, METH_VARARGS, "Log with INFO priority"},
{"log_advanced", log_advanced, METH_VARARGS, "Log with ADVANCED priority"},
{"log_error", log_error, METH_VARARGS, "Log with ERROR priority"},
{"log_debug", log_debug, METH_VARARGS, "Log with DEBUG priority"},
{NULL, NULL, 0, NULL}
};
static PyModuleDef LogModule = {
PyModuleDef_HEAD_INIT, "logging", NULL, -1, LogMethods,
NULL, NULL, NULL, NULL
};
PyObject* PyInit_logging(void)
{
return PyModule_Create(&LogModule);
}