To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.
ZLog SQL: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{External Module}} | {{External Module}} | ||
This is a global Python module for MySQL/SQLite logging. | This is a global Python module for PostgreSQL/MySQL/SQLite logging. | ||
GitHub repository: https://github.com/stil/zlog-sql | GitHub repository: https://github.com/stil/zlog-sql | ||
== Features == | == Features == | ||
* Supports | * Supports PostgreSQL, MySQL, and SQLite databases. | ||
* Asynchronous database writes on separate thread. Guarantees that ZNC won't hang during SQL connection timeout. | * Asynchronous database writes on a separate thread. Guarantees that ZNC won't hang during SQL connection timeout. | ||
* Automatic table creation (CREATE TABLE IF NOT EXIST) | * Automatic table creation (CREATE TABLE IF NOT EXIST) | ||
* Retry after failed inserts. When database server is offline, logs are buffered to memory. They are saved when database is back online | * Retry after failed inserts. When the database server is offline, logs are buffered to memory. They are saved when the database is back online so you won't lose logs during MySQL outages. | ||
== Quick start == | == Quick start == | ||
Line 18: | Line 18: | ||
# Enable module <code>zlog_sql</code> and set its argument. | # Enable module <code>zlog_sql</code> and set its argument. | ||
For MySQL, set module argument matching following format: | For PostgreSQL, set module argument matching the following format: | ||
<pre>postgres://username:password@localhost/database_name</pre> | |||
'''Important:''' you need <code>psycopg2</code> pip package for MySQL logging. Install it with <code>pip3 install psycopg2</code> command. | |||
For MySQL, set module argument matching the following format: | |||
<pre>mysql://username:password@localhost/database_name</pre> | <pre>mysql://username:password@localhost/database_name</pre> | ||
'''Important:''' you need <code>PyMySQL</code> pip package for MySQL logging. Install it with <code>pip3 install PyMySQL</code> command. | '''Important:''' you need <code>PyMySQL</code> pip package for MySQL logging. Install it with <code>pip3 install PyMySQL</code> command. | ||
For SQLite use following string format: | For SQLite use the following string format: | ||
<pre>sqlite:///home/user/logs.sqlite</pre> | <pre>sqlite:///home/user/logs.sqlite</pre> |
Latest revision as of 07:47, 21 May 2019
This is an external module. Please note that it may or may not work with the current release (1.9.1). This module is not included in the default ZNC installation, and you will need to manually compile it before you can load this module. Contact the author if you have any questions, but feel free to ask in #znc on Libera.Chat. Someone might be able to help you there. |
This is a global Python module for PostgreSQL/MySQL/SQLite logging.
GitHub repository: https://github.com/stil/zlog-sql
Features
- Supports PostgreSQL, MySQL, and SQLite databases.
- Asynchronous database writes on a separate thread. Guarantees that ZNC won't hang during SQL connection timeout.
- Automatic table creation (CREATE TABLE IF NOT EXIST)
- Retry after failed inserts. When the database server is offline, logs are buffered to memory. They are saved when the database is back online so you won't lose logs during MySQL outages.
Quick start
- Copy
zlog_sql.py
to~/.znc/modules/zlog_sql.py
. - In Webadmin, open the list of Global Modules.
- Make sure
modpython
is enabled. - Enable module
zlog_sql
and set its argument.
For PostgreSQL, set module argument matching the following format:
postgres://username:password@localhost/database_name
Important: you need psycopg2
pip package for MySQL logging. Install it with pip3 install psycopg2
command.
For MySQL, set module argument matching the following format:
mysql://username:password@localhost/database_name
Important: you need PyMySQL
pip package for MySQL logging. Install it with pip3 install PyMySQL
command.
For SQLite use the following string format:
sqlite:///home/user/logs.sqlite
or simply leave out the path
sqlite
in this case, logs are going to be written to the default path ~/.znc/moddata/zlog_sql/logs.sqlite
.
- Save changes. SQL table schema is going to be created automatically.