mysql UDF that allows for logging to syslog
C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
lib_mysqludf_syslog.c
lib_mysqludf_syslog.sql
lib_mysqludf_syslog_uninstall.sql

README.md

Syslog libary for MySQL. Copyright (C) [Nathan Johnson nathan@nathanjohnson.info]

Function is called as: syslog_write(facility, priority, ident, log_message)

where facility is one of:

 'LOG_AUTH'      The authorization system: login(1), su(1), getty(8), etc.

 'LOG_AUTHPRIV'  The same as LOG_AUTH, but logged to a file readable only by selected individuals.

 'LOG_USER'      Messages generated by random user processes. This is the default facility identifier if none is specified.

 'LOG_DAEMON'    system daemons without separate facility value

 'LOG_LOCAL0'-'LOG_LOCAL7'    Reserved for local use.  Similarly for LOG_LOCAL1 through LOG_LOCAL7.

and priority is one of:

  LOG_EMERG   system is unusable

  LOG_ALERT    action must be taken immediately

  LOG_CRIT       critical conditions

  LOG_ERR        error conditions

  LOG_WARNING warning conditions

  LOG_NOTICE  normal, but significant, condition

  LOG_INFO     informational message

  LOG_DEBUG    debug-level message

ident is prepended to every message, and is typically set to the application name message is what is meant to be sent to syslog

facility, priority and identity should be constant strings. i.e., they should not change while iterating over a result set

to compile (on linux, for example):

gcc `mysql_config --cflags` -fPIC -shared -o lib_mysqludf_syslog.so lib_mysqludf_syslog.c

NOTE: most likely this will never compile on Windows, though it is vaguely possible that it could interface with syslog installed via cygwin.

to create function:

create function lib_mysqludf_syslog_info returns string soname 'lib_mysqludf_syslog.so';
create function syslog_write returns integer soname 'lib_mysqludf_syslog.so';

after copying syslog_udf.so to the appropriate place (plugin dir), or setting LD_LIBRARY_PATH as per the documentation

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA