source: josm/trunk/tools/japicc/modules/Internals/Logging.pm@ 12016

Last change on this file since 12016 was 11682, checked in by Don-vip, 7 years ago

update to japi-compliance-checker 2.1

File size: 2.1 KB
Line 
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###########################################################################
21use strict;
22
23my %DEBUG_DIR;
24
25my %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
45sub exitStatus($$)
46{
47 my ($Code, $Msg) = @_;
48 print STDERR "ERROR: ". $Msg."\n";
49 exit($ERROR_CODE{$Code});
50}
51
52sub getErrorCode($) {
53 return $ERROR_CODE{$_[0]};
54}
55
56sub 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
73sub 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
86sub getDebugDir($) {
87 return $DEBUG_DIR{$_[0]};
88}
89
90return 1;
Note: See TracBrowser for help on using the repository browser.