summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 06adec2)
raw | patch | inline | side by side (parent: 06adec2)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 10 Apr 2007 22:27:54 +0000 (00:27 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 11 Apr 2007 06:46:18 +0000 (08:46 +0200) |
This adds the following function to collectd's Perl API:
Collectd::plugin_log:
pass a message to collectd's logging mechanism
arguments:
level - log level
message - log message
The log level should be any of the Collectd::LOG_* constants.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Collectd::plugin_log:
pass a message to collectd's logging mechanism
arguments:
level - log level
message - log message
The log level should be any of the Collectd::LOG_* constants.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
src/collectd.pod | patch | blob | history | |
src/perl.c | patch | blob | history |
diff --git a/src/collectd.pod b/src/collectd.pod
index 08524901d982a7357075f31fa75906880e3e0fa7..6d29804981e4b72ec04b0a40bfbc35b31a113f91 100644 (file)
--- a/src/collectd.pod
+++ b/src/collectd.pod
=item
+Embedded Perl interpreter (I<perl>)
+
+=item
+
Network latency (I<ping>)
=item
=head2 perl
The C<perl plugin> includes a Perl-interpreter in collectd and provides
-Perl-equvalents of the plugin-functions. This makes it possible to write
+Perl-equivalents of the plugin-functions. This makes it possible to write
plugins in Perl.
-There are two more comlex types you need to know about:
+There are two more complex types you need to know about:
=over 4
data-source. For the exact layout see B<Data-Set> above.
If the I<type> argument is any of the other types (B<TYPE_INIT>, B<TYPE_READ>,
-...) when I<data> is expected to be a funtion reference. These functions are
+...) then I<data> is expected to be a function reference. These functions are
called in the various stages of the daemon and are passed the following
arguments:
=item B<plugin_log> (I<log-level>, I<message>)
-TODO.
+Submits a I<message> of level I<log-level> to collectd's logging mechanism.
+The message is passed to all log-callbacks that are registered with collectd.
=back
diff --git a/src/perl.c b/src/perl.c
index 0c5e8829556c17b70a1e62ca4604ba454f4de7cd..294f69a29018207dd28c2f8b32b5026bd52c73a0 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
static XS (Collectd_plugin_register);
static XS (Collectd_plugin_unregister);
static XS (Collectd_plugin_dispatch_values);
+static XS (Collectd_plugin_log);
/*
{ "Collectd::plugin_register", Collectd_plugin_register },
{ "Collectd::plugin_unregister", Collectd_plugin_unregister },
{ "Collectd::plugin_dispatch_values", Collectd_plugin_dispatch_values },
+ { "Collectd::plugin_log", Collectd_plugin_log },
{ "", NULL }
};
dXSARGS;
- items = 2;
if (2 != items) {
log_err ("Usage: Collectd::plugin_dispatch_values(name, values)");
XSRETURN_EMPTY;
XSRETURN_EMPTY;
} /* static XS (Collectd_plugin_dispatch_values) */
+/*
+ * Collectd::plugin_log (level, message).
+ *
+ * level:
+ * log level (LOG_DEBUG, ... LOG_ERR)
+ *
+ * message:
+ * log message
+ */
+static XS (Collectd_plugin_log)
+{
+ dXSARGS;
+
+ if (2 != items) {
+ log_err ("Usage: Collectd::plugin_log(level, message)");
+ XSRETURN_EMPTY;
+ }
+
+ log_debug ("Collectd::plugin_log: level = %i, message = \"%s\"",
+ SvIV (ST (0)), SvPV_nolen (ST (1)));
+ plugin_log (SvIV (ST (0)), SvPV_nolen (ST (1)));
+ XSRETURN_YES;
+} /* static XS (Collectd_plugin_log) */
+
/*
* Collectd::bootstrap ().
*/