
Log::Handler::Plugin::DBI::CreateTable - A helper for Log::Hander::Output::DBI to create your 'log' table

See scripts/create.table.pl and scripts/drop.table.pl.
The programs use these methods: "create_log_table()" and "drop_log_table()".

This module is a customised wrapper for DBIx::Admin::CreateTable, which means it handles a range of database server SQL formats for creating tables and the corresponding sequences.
Likewise for dropping tables and sequences.
The table name defaults to 'log', and it has the correct structure to be compatible with Log::Handler::Output::DBI.

This module is available as a Unix-style distro (*.tgz).
See http://savage.net.au/Perl-modules/html/installing-a-module.html for help on unpacking and installing distros.

Install Log::Handler::Plugin::DBI as you would for any Perl module:
Run:
cpanm Log::Handler::Plugin::DBI
or run:
sudo cpan Log::Handler::Plugin::DBI
or unpack the distro, and then either:
perl Build.PL
./Build
./Build test
sudo ./Build install
or:
perl Makefile.PL
make (or dmake or nmake)
make test
make install

new() is called as my($app) = Log::Handler::Plugin::DBI::CreateTable -> new(k1 => v1, k2 => v2, ...).
It returns a new object of type Log::Handler::Plugin::DBI::CreateTable.
Key-value pairs accepted in the parameter list (see corresponding methods for details [e.g. "config([$hashref])"]):
The keys and values of this hashref are documented below under "config([$hashref])".

Gets or sets the hashref of options used by the other methods.
Here, the [] indicate an optional parameter.
The hashref takes these (key => value) pairs:
A typical $string might be 'dbi:SQLite:dbname=/tmp/logger.test.sqlite'.
Supply your database server username, or leave empty for databases such as SQLite.
Supply your database server password, or leave empty for databases such as SQLite.
Supply your log table name, or let it default to 'log'.
'config' is a parameter to "new()". See "Constructor and Initialization" for details.
Creates the table named in the config hashref passed in to new.
Drops the table named in the config hashref passed in to new.

You use scripts/*.pl in preparation for using any class or program which you want to log to a database.
Having create the 'log' table, then you write code using Log::Handler::Plugin::DBI.
For sample code, study CGI::Snapp::Demo::Four.
In pseudo-code:
id primary key + (db_vendor-dependent stuff)
level varchar(255) not null,
message not null + (db_vendor eq 'ORACLE' ? 'long' : 'text')
timestamp timestamp not null default current_timestamp +
(db_vendor =~ /(?:MySQL|Postgres)/i ? '(0) without time zone' : '')
Also, if you're using MySQL, you might want to set the engine=innodb option.
See scripts/create.table.pl and scripts/drop.table.pl for an easy way to do all this.
Sure, but it's not a plugin like Log::Handler::Plugin::DBI is.

The following are all part of this set of distros:
CGI::Snapp - A almost back-compat fork of CGI::Application

The following are all part of this set of distros:
CGI::Snapp - A almost back-compat fork of CGI::Application
CGI::Snapp::Demo::One - A template-free demo of CGI::Snapp using just 1 run mode
CGI::Snapp::Demo::Two - A template-free demo of CGI::Snapp using N run modes
CGI::Snapp::Demo::Three - A template-free demo of CGI::Snapp using the forward() method
CGI::Snapp::Demo::Four - A template-free demo of CGI::Snapp using Log::Handler::Plugin::DBI
CGI::Snapp::Demo::Four::Wrapper - A wrapper around CGI::Snapp::Demo::Four, to simplify using Log::Handler::Plugin::DBI
Config::Plugin::Tiny - A plugin which uses Config::Tiny
Config::Plugin::TinyManifold - A plugin which uses Config::Tiny with 1 of N sections
Data::Session - Persistent session data management
Log::Handler::Plugin::DBI - A plugin for Log::Handler using Log::Hander::Output::DBI
Log::Handler::Plugin::DBI::CreateTable - A helper for Log::Hander::Output::DBI to create your 'log' table

The file CHANGES was converted into Changelog.ini by Module::Metadata::Changes.

Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.

Please read https://metacpan.org/module/CGI::Application::Plugin::Config::Simple#AUTHOR, since a lot of the ideas for this module were copied from CGI::Application::Plugin::Config::Simple.

Email the author, or log a bug on RT:
https://rt.cpan.org/Public/Dist/Display.html?Name=Log::Handler::Plugin::DBI.

Log::Handler::Plugin::DBI::CreateTable was written by Ron Savage <ron@savage.net.au> in 2012.
Home page: http://savage.net.au/index.html.

Australian copyright (c) 2012, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Artistic License, a copy of which is available at:
http://www.opensource.org/licenses/index.html