| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#! /usr/bin/env perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
568
|
use v5.10; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#=================================== |
|
7
|
|
|
|
|
|
|
package ClobalConstructor; |
|
8
|
|
|
|
|
|
|
#=================================== |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
792
|
use Moo; |
|
|
1
|
|
|
|
|
16518
|
|
|
|
1
|
|
|
|
|
7
|
|
|
11
|
1
|
|
|
1
|
|
2261
|
use Kaiten::Container; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
510
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'config' => ( is => 'rw', ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub create_container { |
|
16
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
17
|
1
|
|
|
|
|
11
|
my $config = $self->config; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $init_conf = { |
|
20
|
|
|
|
|
|
|
host_production => { |
|
21
|
1
|
|
|
1
|
|
8
|
handler => sub { 'www.coolsite.com' }, |
|
22
|
1
|
|
|
1
|
|
3
|
probe => sub { 1 } |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
host_develop => { |
|
25
|
0
|
|
|
0
|
|
0
|
handler => sub { 'localhost' }, |
|
26
|
0
|
|
|
0
|
|
0
|
probe => sub { 1 } |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
host_full_name => { |
|
29
|
|
|
|
|
|
|
handler => sub { |
|
30
|
1
|
|
|
1
|
|
7
|
my $c = shift; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# no need checking - if entity absence - all die |
|
33
|
1
|
|
|
|
|
5
|
my $host = $c->get_by_name( 'host_' . $config->{mode} ); |
|
34
|
1
|
|
|
|
|
3
|
return $host; |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
1
|
|
|
1
|
|
3
|
probe => sub { 1 } |
|
37
|
|
|
|
|
|
|
}, |
|
38
|
|
|
|
|
|
|
debug_level => { |
|
39
|
|
|
|
|
|
|
handler => sub { |
|
40
|
0
|
|
|
0
|
|
0
|
die 'original method have huge dependecies'; |
|
41
|
|
|
|
|
|
|
}, |
|
42
|
0
|
|
|
0
|
|
0
|
probe => sub { shift } |
|
43
|
|
|
|
|
|
|
}, |
|
44
|
|
|
|
|
|
|
system_logger => { |
|
45
|
|
|
|
|
|
|
handler => sub { |
|
46
|
1
|
|
|
1
|
|
8
|
my $c = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
6
|
my $debugger = $c->get_by_name('logger_engine'); |
|
49
|
1
|
|
|
|
|
4
|
my $level = $c->get_by_name('debug_level'); |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
5
|
$debugger->set_level($level); |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
3
|
return $debugger; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
}, |
|
56
|
1
|
|
|
1
|
|
4
|
probe => sub { 1 } |
|
57
|
|
|
|
|
|
|
}, |
|
58
|
|
|
|
|
|
|
deadly_things => { |
|
59
|
|
|
|
|
|
|
handler => sub { |
|
60
|
0
|
|
|
0
|
|
0
|
die 'just died if you touch this'; |
|
61
|
|
|
|
|
|
|
}, |
|
62
|
0
|
|
|
0
|
|
0
|
probe => sub { shift } |
|
63
|
|
|
|
|
|
|
}, |
|
64
|
1
|
|
|
|
|
29
|
}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
5
|
my $container = Kaiten::Container->new( init => $init_conf ) |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#=================================== |
|
72
|
|
|
|
|
|
|
package LoggerEngine; |
|
73
|
|
|
|
|
|
|
#=================================== |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
1
|
|
12
|
use Moo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has 'level' => ( |
|
78
|
|
|
|
|
|
|
is => 'rw', |
|
79
|
|
|
|
|
|
|
writer => 'set_level', |
|
80
|
|
|
|
|
|
|
default => sub { 0 }, |
|
81
|
|
|
|
|
|
|
); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub output { |
|
84
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
85
|
1
|
|
|
|
|
2
|
my $message = shift; |
|
86
|
|
|
|
|
|
|
|
|
87
|
1
|
50
|
|
|
|
127
|
say( ( $self->level ? 'DEBUG ON: ' : 'DEBUG OFF: ' ) . $message ); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub self_check { |
|
92
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
93
|
1
|
|
|
|
|
2
|
my $message = shift; |
|
94
|
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
398
|
say "** CHECK:[$message] **"; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#=================================== |
|
101
|
|
|
|
|
|
|
package main; |
|
102
|
|
|
|
|
|
|
#=================================== |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $stable_config = { |
|
105
|
|
|
|
|
|
|
mode => 'production', |
|
106
|
|
|
|
|
|
|
}; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $global_constructor = ClobalConstructor->new( config => $stable_config ); |
|
109
|
|
|
|
|
|
|
my $container = $global_constructor->create_container(); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $logger_engine_conf = { |
|
112
|
|
|
|
|
|
|
handler => sub { LoggerEngine->new() }, |
|
113
|
|
|
|
|
|
|
probe => sub { |
|
114
|
|
|
|
|
|
|
my $self = shift; |
|
115
|
|
|
|
|
|
|
$self->self_check( 'self-testing at livel [' . $self->level . '] ok' ) |
|
116
|
|
|
|
|
|
|
}, |
|
117
|
|
|
|
|
|
|
}; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$container->add( 'logger_engine' => $logger_engine_conf ); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# ok, its seems little complexly, but this way can used to replace handler with mock |
|
122
|
|
|
|
|
|
|
my $mock_object = { |
|
123
|
|
|
|
|
|
|
handler => sub { 1 }, |
|
124
|
|
|
|
|
|
|
probe => sub { 1 } |
|
125
|
|
|
|
|
|
|
}; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$container->remove('debug_level')->add( 'debug_level' => $mock_object ); |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $logger = $container->get_by_name('system_logger'); |
|
130
|
|
|
|
|
|
|
my $full_name = $container->get_by_name('host_full_name'); |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$logger->output( 'it is worked at - ' . $full_name ); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
say 'all ok'; |