author | Bob Rosenberg <bob.rosenberg@nokia.com> |
Tue, 06 Apr 2010 10:28:27 +0100 | |
branch | HighFidelityModel |
changeset 152 | 5acf50bbb618 |
permissions | -rw-r--r-- |
152
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
1 |
################################################################################################## |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
2 |
# |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
3 |
# Package: LogItem |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
4 |
# |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
5 |
################################################################################################## |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
6 |
package LogItem; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
7 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
8 |
use FindBin; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
9 |
use lib $FindBin::Bin; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
10 |
use strict; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
11 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
12 |
use constant ERROR => 1; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
13 |
use constant WARNING => 2; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
14 |
use constant INFO => 3; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
15 |
use constant VERBOSE => 4; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
16 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
17 |
#------------------------------------------------------------------------------------------------- |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
18 |
# Subroutine: new |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
19 |
# Purpose: Constructor |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
20 |
# Input: None (extracted from command line args) |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
21 |
# Output: A reference to itself |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
22 |
#------------------------------------------------------------------------------------------------- |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
23 |
sub new() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
24 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
25 |
my $package = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
26 |
my $self = {}; # Create reference to object |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
27 |
bless $self, $package; # Associate a reference with class name |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
28 |
my %parameters = @_; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
29 |
$self->{iMessage} = $parameters{'msg'} ? $parameters{'msg'} : ""; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
30 |
$self->{iCode} = $parameters{'code'} ? $parameters{'code'} : 0; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
31 |
$self->{iModule} = $parameters{'module'} ? $parameters{'module'} : 0; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
32 |
$self->{iSeverity} = $parameters{'severity'} ? $parameters{'severity'} : 3; # default is INFO |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
33 |
$self->{iDepth} = $parameters{'depth'} ? $parameters{'depth'} : 0; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
34 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
35 |
$self->{iCode} = 0; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
36 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
37 |
$self->{iDate} = scalar(localtime); |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
38 |
return $self; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
39 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
40 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
41 |
sub Message() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
42 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
43 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
44 |
$self->{iMessage} = $_[0] if $_[0]; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
45 |
return $self->{iMessage}; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
46 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
47 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
48 |
sub Module() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
49 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
50 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
51 |
$self->{iModule} = $_[0] if $_[0]; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
52 |
return $self->{iModule}; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
53 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
54 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
55 |
sub Severity() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
56 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
57 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
58 |
$self->{iSeverity} = $_[0] if $_[0]; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
59 |
return $self->{iSeverity}; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
60 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
61 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
62 |
sub Depth() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
63 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
64 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
65 |
$self->{iDepth} = $_[0] if $_[0]; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
66 |
return $self->{iDepth}; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
67 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
68 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
69 |
sub Date() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
70 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
71 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
72 |
$self->{iDate} = $_[0] if $_[0]; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
73 |
return $self->{iDate}; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
74 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
75 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
76 |
sub Code() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
77 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
78 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
79 |
$self->{iCode} = $_[0] if $_[0]; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
80 |
return $self->{iCode}; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
81 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
82 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
83 |
sub LogText() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
84 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
85 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
86 |
return $self->SeverityText()."(".$self->{iCode}.") [".$self->{iDate}."]: "." " x $self->{iDepth}.$self->{iMessage}."\n"; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
87 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
88 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
89 |
sub SeverityText() |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
90 |
{ |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
91 |
my $self = shift; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
92 |
return " ERROR" if $self->Severity() == ERROR; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
93 |
return "WARNING" if $self->Severity() == WARNING; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
94 |
return "VERBOSE" if $self->Severity() == VERBOSE; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
95 |
return " INFO"; |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
96 |
} |
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
97 |
|
5acf50bbb618
Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
98 |
1; |