https://github.com/cyclonecode/udf-logger
UDF which sends log messages using curl.
https://github.com/cyclonecode/udf-logger
c curl mysql udf
Last synced: about 1 month ago
JSON representation
UDF which sends log messages using curl.
- Host: GitHub
- URL: https://github.com/cyclonecode/udf-logger
- Owner: Cyclonecode
- Created: 2021-12-07T14:03:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-09T13:35:27.000Z (over 4 years ago)
- Last Synced: 2025-08-25T02:26:42.757Z (10 months ago)
- Topics: c, curl, mysql, udf
- Language: C
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UDF Logger
Sample UDF which can be used to post messages to an URL.
The extension is using curl to send messages.
## Requirements
You need to the development package for curl and mysql installed.
sudo apt-get update && sudo apt-get install -y libmysqlclient-dev libcurl4-openssl-dev
## Installing
When the needed headers and libraries are installed, make sure you update the `makefile` with the correct paths before building your shared library:
make SERVER=http://localhost:8080 INCLUDE="-I/usr/include/mysql -I/include/x86_64-linux-gnu/curl" LDFLAGS="-L/usr/lib/x86_64-linux-gnu"
After we have built the shared library we need to copy it into our mysql plugin directory:
cp logger.so `mysql_config --plugindir`
Now we need to tell mysql about our extension:
sudo mysql -uroot
DROP FUNCTION IF EXISTS udfLog;
CREATE FUNCTION udfLog RETURNS STRING SONAME 'logger.so';
After this you could start a server running on the same host as your mysql instance and on port 8080.
You could of course use anything for this, even just using the built in php webserver:
php -S localhost:8080
and then say greet it:
SELECT udfLog("Greetings dark night!");