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