1 | ###########################################################################
|
---|
2 | # A module for logging
|
---|
3 | #
|
---|
4 | # Copyright (C) 2016-2017 Andrey Ponomarenko's ABI Laboratory
|
---|
5 | #
|
---|
6 | # Written by Andrey Ponomarenko
|
---|
7 | #
|
---|
8 | # This program is free software: you can redistribute it and/or modify
|
---|
9 | # it under the terms of the GNU General Public License or the GNU Lesser
|
---|
10 | # General Public License as published by the Free Software Foundation.
|
---|
11 | #
|
---|
12 | # This program is distributed in the hope that it will be useful,
|
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | # GNU General Public License for more details.
|
---|
16 | #
|
---|
17 | # You should have received a copy of the GNU General Public License
|
---|
18 | # and the GNU Lesser General Public License along with this program.
|
---|
19 | # If not, see <http://www.gnu.org/licenses/>.
|
---|
20 | ###########################################################################
|
---|
21 | use strict;
|
---|
22 |
|
---|
23 | my %DEBUG_DIR;
|
---|
24 |
|
---|
25 | my %ERROR_CODE = (
|
---|
26 | # Compatible verdict
|
---|
27 | "Compatible"=>0,
|
---|
28 | "Success"=>0,
|
---|
29 | # Incompatible verdict
|
---|
30 | "Incompatible"=>1,
|
---|
31 | # Undifferentiated error code
|
---|
32 | "Error"=>2,
|
---|
33 | # System command is not found
|
---|
34 | "Not_Found"=>3,
|
---|
35 | # Cannot access input files
|
---|
36 | "Access_Error"=>4,
|
---|
37 | # Invalid input API dump
|
---|
38 | "Invalid_Dump"=>7,
|
---|
39 | # Incompatible version of API dump
|
---|
40 | "Dump_Version"=>8,
|
---|
41 | # Cannot find a module
|
---|
42 | "Module_Error"=>9
|
---|
43 | );
|
---|
44 |
|
---|
45 | sub exitStatus($$)
|
---|
46 | {
|
---|
47 | my ($Code, $Msg) = @_;
|
---|
48 | print STDERR "ERROR: ". $Msg."\n";
|
---|
49 | exit($ERROR_CODE{$Code});
|
---|
50 | }
|
---|
51 |
|
---|
52 | sub getErrorCode($) {
|
---|
53 | return $ERROR_CODE{$_[0]};
|
---|
54 | }
|
---|
55 |
|
---|
56 | sub printMsg($$)
|
---|
57 | {
|
---|
58 | my ($Type, $Msg) = @_;
|
---|
59 | if($Type!~/\AINFO/) {
|
---|
60 | $Msg = $Type.": ".$Msg;
|
---|
61 | }
|
---|
62 | if($Type!~/_C\Z/) {
|
---|
63 | $Msg .= "\n";
|
---|
64 | }
|
---|
65 | if($Type eq "ERROR") {
|
---|
66 | print STDERR $Msg;
|
---|
67 | }
|
---|
68 | else {
|
---|
69 | print $Msg;
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | sub initLogging($)
|
---|
74 | {
|
---|
75 | my $LVer = $_[0];
|
---|
76 | if($In::Opt{"Debug"})
|
---|
77 | { # debug directory
|
---|
78 | $DEBUG_DIR{$LVer} = "debug/".$In::Opt{"TargetLib"}."/".$In::Desc{$LVer}{"Version"};
|
---|
79 |
|
---|
80 | if(-d $DEBUG_DIR{$LVer}) {
|
---|
81 | rmtree($DEBUG_DIR{$LVer});
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | sub getDebugDir($) {
|
---|
87 | return $DEBUG_DIR{$_[0]};
|
---|
88 | }
|
---|
89 |
|
---|
90 | return 1;
|
---|