File: TestAppSingleton.pm

package info (click to toggle)
libcgi-application-basic-plugin-bundle-perl 0.5-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,348 kB
  • ctags: 285
  • sloc: perl: 4,924; sh: 31; makefile: 9
file content (73 lines) | stat: -rw-r--r-- 1,912 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package TestAppSingleton;

use strict;
use vars qw($HANDLE);

use DummyIOHandle;
BEGIN { $HANDLE = new DummyIOHandle; };
use CGI::Application;
use CGI::Application::Plugin::LogDispatch (
              LOG_DISPATCH_MODULES => [
                          {
                            module         => 'Log::Dispatch::Handle',
                            name           => 'handle',
                            min_level      => 'info',
                            handle         => $HANDLE,
                          },
              ],
);
@TestAppSingleton::ISA = qw(CGI::Application);

sub setup {
    my $self = shift;
    $self->start_mode('test_mode');
    $self->run_modes(test_mode => 'test_mode' );
}

sub test_mode {
    my $self = shift;

    $self->log->debug("log singleton debug");
    $self->log->info('log singleton info');
    return "test_mode return value";
}

package TestAppSingleton::Sub;

use strict;
use vars qw($HANDLE);

use DummyIOHandle;
BEGIN { $HANDLE = new DummyIOHandle; };
use CGI::Application;
use CGI::Application::Plugin::LogDispatch (
              LOG_DISPATCH_OPTIONS => {
                        callbacks => sub { my %h = @_; chomp $h{message}; return $h{message}.'EXTRA'; },
              },
              LOG_DISPATCH_MODULES => [
                          {
                            module         => 'Log::Dispatch::Handle',
                            name           => 'handle',
                            min_level      => 'info',
                            handle         => $HANDLE,
                          },
              ],
);
@TestAppSingleton::Sub::ISA = qw(TestAppSingleton);

package TestAppSingleton::Sub2;

use strict;
use vars qw($HANDLE);

use CGI::Application;
@TestAppSingleton::Sub2::ISA = qw(TestAppSingleton);

sub test_mode {
    my $self = shift;

    $self->log->info('log subsingleton info');
    return "test_mode return value";
}

1;