diff options
author | Emmanuel Bouthenot <kolter@openics.org> | 2006-02-16 16:10:25 +0000 |
---|---|---|
committer | Emmanuel Bouthenot <kolter@openics.org> | 2006-02-16 16:10:25 +0000 |
commit | 8855d39f44892dc91f7aaef536e49082ff8517f7 (patch) | |
tree | 229d3b42fd7dcbeff57a6b4b1f4c6f32fb68bf51 /src/plugins/scripts/perl/weechat-perl.c | |
parent | 91af3fe7285267bffceebc5e09575c4b93025ce0 (diff) | |
download | weechat-8855d39f44892dc91f7aaef536e49082ff8517f7.zip |
make possible to log with plugins / scripts
Diffstat (limited to 'src/plugins/scripts/perl/weechat-perl.c')
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index ca20365d2..d50bf1d8f 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -337,6 +337,54 @@ static XS (XS_weechat_print_infobar) } /* + * weechat::log: log message in server/channel (current or specified ones) + */ + +static XS (XS_weechat_log) +{ + unsigned int integer; + char *message, *channel_name, *server_name; + dXSARGS; + + /* make gcc happy */ + (void) cv; + + if (!perl_current_script) + { + perl_plugin->printf_server (perl_plugin, + "Perl error: unable to print message, " + "script not initialized"); + XSRETURN_NO; + } + + if (items < 1) + { + perl_plugin->printf_server (perl_plugin, + "Perl error: wrong parameters for " + "\"log\" function"); + XSRETURN_NO; + } + + message = SvPV (ST (0), integer); + + channel_name = NULL; + server_name = NULL; + + if (items > 1) + { + channel_name = SvPV (ST (1), integer); + if (items > 2) + server_name = SvPV (ST (2), integer); + } + + perl_plugin->log (perl_plugin, + server_name, channel_name, + "%s", message); + + XSRETURN_YES; +} + +/* * weechat::command: send command to server */ @@ -1032,6 +1080,7 @@ weechat_perl_xs_init (pTHX) newXS ("weechat::register", XS_weechat_register, "weechat"); newXS ("weechat::print", XS_weechat_print, "weechat"); newXS ("weechat::print_infobar", XS_weechat_print_infobar, "weechat"); + newXS ("weechat::log", XS_weechat_log, "weechat"); newXS ("weechat::command", XS_weechat_command, "weechat"); newXS ("weechat::add_message_handler", XS_weechat_add_message_handler, "weechat"); newXS ("weechat::add_command_handler", XS_weechat_add_command_handler, "weechat"); |