mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added log calls to API
This commit is contained in:
parent
1ed339f82b
commit
5a4446dfac
@ -24,6 +24,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "plugins/callbacks.h"
|
||||
#include "profanity.h"
|
||||
#include "ui/notifier.h"
|
||||
@ -99,3 +100,27 @@ api_get_current_recipient(void)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
api_log_debug(const char *message)
|
||||
{
|
||||
log_debug("%s", message);
|
||||
}
|
||||
|
||||
void
|
||||
api_log_info(const char *message)
|
||||
{
|
||||
log_info("%s", message);
|
||||
}
|
||||
|
||||
void
|
||||
api_log_warning(const char *message)
|
||||
{
|
||||
log_warning("%s", message);
|
||||
}
|
||||
|
||||
void
|
||||
api_log_error(const char *message)
|
||||
{
|
||||
log_error("%s", message);
|
||||
}
|
||||
|
@ -37,4 +37,9 @@ void api_register_command(const char *command_name, int min_args, int max_args,
|
||||
void api_register_timed(void *callback, int interval_seconds,
|
||||
void (*callback_func)(PluginTimedFunction *timed_function));
|
||||
|
||||
void api_log_debug(const char *message);
|
||||
void api_log_info(const char *message);
|
||||
void api_log_warning(const char *message);
|
||||
void api_log_error(const char *message);
|
||||
|
||||
#endif
|
||||
|
@ -87,6 +87,30 @@ c_api_get_current_recipient(void)
|
||||
return api_get_current_recipient();
|
||||
}
|
||||
|
||||
static void
|
||||
c_api_log_debug(const char *message)
|
||||
{
|
||||
api_log_debug(message);
|
||||
}
|
||||
|
||||
static void
|
||||
c_api_log_info(const char *message)
|
||||
{
|
||||
api_log_info(message);
|
||||
}
|
||||
|
||||
static void
|
||||
c_api_log_warning(const char *message)
|
||||
{
|
||||
api_log_warning(message);
|
||||
}
|
||||
|
||||
static void
|
||||
c_api_log_error(const char *message)
|
||||
{
|
||||
api_log_error(message);
|
||||
}
|
||||
|
||||
void
|
||||
c_command_callback(PluginCommand *command, gchar **args)
|
||||
{
|
||||
@ -113,4 +137,8 @@ c_api_init(void)
|
||||
prof_notify = c_api_notify;
|
||||
prof_send_line = c_api_send_line;
|
||||
prof_get_current_recipient = c_api_get_current_recipient;
|
||||
prof_log_debug = c_api_log_debug;
|
||||
prof_log_info = c_api_log_info;
|
||||
prof_log_warning = c_api_log_warning;
|
||||
prof_log_error = c_api_log_error;
|
||||
}
|
||||
|
@ -38,3 +38,8 @@ void (*prof_notify)(const char *message, int timeout_ms, const char *category) =
|
||||
void (*prof_send_line)(char *line) = NULL;
|
||||
|
||||
char* (*prof_get_current_recipient)(void) = NULL;
|
||||
|
||||
void (*prof_log_debug)(const char *message) = NULL;
|
||||
void (*prof_log_info)(const char *message) = NULL;
|
||||
void (*prof_log_warning)(const char *message) = NULL;
|
||||
void (*prof_log_error)(const char *message) = NULL;
|
||||
|
@ -38,4 +38,9 @@ void (*prof_send_line)(char *line);
|
||||
|
||||
char* (*prof_get_current_recipient)(void);
|
||||
|
||||
void (*prof_log_debug)(const char *message);
|
||||
void (*prof_log_info)(const char *message);
|
||||
void (*prof_log_warning)(const char *message);
|
||||
void (*prof_log_error)(const char *message);
|
||||
|
||||
#endif
|
||||
|
@ -40,7 +40,7 @@ python_api_cons_show(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "s", &message)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
api_cons_show(message);
|
||||
return Py_BuildValue("");
|
||||
@ -59,7 +59,7 @@ python_api_register_command(PyObject *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "siisssO", &command_name, &min_args, &max_args,
|
||||
&usage, &short_help, &long_help, &p_callback)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
if (p_callback && PyCallable_Check(p_callback)) {
|
||||
@ -77,7 +77,7 @@ python_api_register_timed(PyObject *self, PyObject *args)
|
||||
int interval_seconds = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Oi", &p_callback, &interval_seconds)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
if (p_callback && PyCallable_Check(p_callback)) {
|
||||
@ -95,7 +95,7 @@ python_api_notify(PyObject *self, PyObject *args)
|
||||
int timeout_ms = 5000;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sis", &message, &timeout_ms, &category)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
api_notify(message, category, timeout_ms);
|
||||
@ -108,7 +108,7 @@ python_api_send_line(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *line = NULL;
|
||||
if (!PyArg_ParseTuple(args, "s", &line)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
api_send_line(line);
|
||||
@ -127,6 +127,50 @@ python_api_get_current_recipient(PyObject *self, PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
python_api_log_debug(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "s", &message)) {
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
api_log_debug(message);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
python_api_log_info(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "s", &message)) {
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
api_log_info(message);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
python_api_log_warning(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "s", &message)) {
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
api_log_warning(message);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
python_api_log_error(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "s", &message)) {
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
api_log_error(message);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
void
|
||||
python_command_callback(PluginCommand *command, gchar **args)
|
||||
{
|
||||
@ -182,6 +226,10 @@ static PyMethodDef apiMethods[] = {
|
||||
{ "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." },
|
||||
{ "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
|
||||
{ "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
|
||||
{ "log_debug", python_api_log_debug, METH_VARARGS, "Log a debug message" },
|
||||
{ "log_info", python_api_log_info, METH_VARARGS, "Log an info message" },
|
||||
{ "log_warning", python_api_log_warning, METH_VARARGS, "Log a warning message" },
|
||||
{ "log_error", python_api_log_error, METH_VARARGS, "Log an error message" },
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
@ -107,6 +107,50 @@ ruby_api_get_current_recipient(VALUE self)
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ruby_api_log_debug(VALUE self, VALUE v_message)
|
||||
{
|
||||
char *message = STR2CSTR(v_message);
|
||||
|
||||
if (message != NULL) {
|
||||
api_log_debug(message);
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ruby_api_log_info(VALUE self, VALUE v_message)
|
||||
{
|
||||
char *message = STR2CSTR(v_message);
|
||||
|
||||
if (message != NULL) {
|
||||
api_log_info(message);
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ruby_api_log_warning(VALUE self, VALUE v_message)
|
||||
{
|
||||
char *message = STR2CSTR(v_message);
|
||||
|
||||
if (message != NULL) {
|
||||
api_log_warning(message);
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ruby_api_log_error(VALUE self, VALUE v_message)
|
||||
{
|
||||
char *message = STR2CSTR(v_message);
|
||||
|
||||
if (message != NULL) {
|
||||
api_log_error(message);
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void
|
||||
ruby_command_callback(PluginCommand *command, gchar **args)
|
||||
{
|
||||
@ -157,4 +201,8 @@ ruby_api_init(void)
|
||||
rb_define_module_function(prof_module, "send_line", RUBY_METHOD_FUNC(ruby_api_send_line), 1);
|
||||
rb_define_module_function(prof_module, "notify", RUBY_METHOD_FUNC(ruby_api_notify), 3);
|
||||
rb_define_module_function(prof_module, "get_current_recipient", RUBY_METHOD_FUNC(ruby_api_get_current_recipient), 0);
|
||||
rb_define_module_function(prof_module, "log_debug", RUBY_METHOD_FUNC(ruby_api_log_debug), 1);
|
||||
rb_define_module_function(prof_module, "log_info", RUBY_METHOD_FUNC(ruby_api_log_info), 1);
|
||||
rb_define_module_function(prof_module, "log_warning", RUBY_METHOD_FUNC(ruby_api_log_warning), 1);
|
||||
rb_define_module_function(prof_module, "log_error", RUBY_METHOD_FUNC(ruby_api_log_error), 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user