more changes to the way debug output works
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Replicated / WithDSN.pm
CommitLineData
ee356d00 1package DBIx::Class::Storage::DBI::Replicated::WithDSN;
2
3use Moose::Role;
4requires qw/_query_start/;
5
6use namespace::clean -except => 'meta';
7
8=head1 NAME
9
10DBIx::Class::Storage::DBI::Replicated::WithDSN - A DBI Storage Role with DSN
11information in trace output
12
13=head1 SYNOPSIS
14
15This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>.
16
17=head1 DESCRIPTION
18
19This role adds C<DSN: > info to storage debugging output.
20
21=head1 METHODS
22
23This class defines the following methods.
24
25=head2 around: _query_start
26
27Add C<DSN: > to debugging output.
28
29=cut
30
31around '_query_start' => sub {
32 my ($method, $self, $sql, @bind) = @_;
33 my $dsn = $self->_dbi_connect_info->[0];
bd5da369 34 my($op, $rest) = ($sql=~m/^(\w+) (.+)$/);
1fa4a3e2 35
36 my $storage_type = $self->can('active') ? 'REPLICANT' : 'MASTER';
37
38 $self->$method("$op [DSN_$storage_type=$dsn] $rest", @bind);
ee356d00 39};
40
41=head1 ALSO SEE
42
43L<DBIx::Class::Storage::DBI>
44
45=head1 AUTHOR
46
47John Napiorkowski <john.napiorkowski@takkle.com>
48
49=head1 LICENSE
50
51You may distribute this code under the same terms as Perl itself.
52
53=cut
54
551;