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:
Perl
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, ...).
new()
my($app) = Log::Handler::Plugin::DBI::CreateTable -> new(k1 => v1, k2 => v2, ...)
It returns a new object of type Log::Handler::Plugin::DBI::CreateTable.
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 are 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 is not a plugin like Log::Handler::Plugin::DBI is.
Config::Plugin::Tiny - A plugin which uses Config::Tiny
Config::Plugin::TinyManifold - A plugin which uses Config::Tiny with 1 of N sections
Log::Handler::Plugin::DBI - A plugin for Log::Handler using Log::Hander::Output::DBI
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.
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
To install Log::Handler::Plugin::DBI, copy and paste the appropriate command in to your terminal.
cpanm
CPAN shell
perl -MCPAN -e shell install Log::Handler::Plugin::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.