summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b3b7e5)
raw | patch | inline | side by side (parent: 3b3b7e5)
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:27:31 +0000 (08:27 +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 566a62c7eefee4c345df8512119708c5fdeb2050..48da338910cacb4779d5ebf3180bd2d49aee9c65 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 ().
*/