/usr/share/abi-compliance-checker/modules/Internals/Logging.pm is in abi-compliance-checker 2.2-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | ###########################################################################
# A module for logging
#
# Copyright (C) 2015-2016 Andrey Ponomarenko's ABI Laboratory
#
# Written by Andrey Ponomarenko
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License or the GNU Lesser
# General Public License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# and the GNU Lesser General Public License along with this program.
# If not, see <http://www.gnu.org/licenses/>.
###########################################################################
use strict;
my (%LOG_PATH, %DEBUG_DIR);
my %ERROR_CODE = (
# Compatible verdict
"Compatible"=>0,
"Success"=>0,
# Incompatible verdict
"Incompatible"=>1,
# Undifferentiated error code
"Error"=>2,
# System command is not found
"Not_Found"=>3,
# Cannot access input files
"Access_Error"=>4,
# Cannot compile header files
"Cannot_Compile"=>5,
# Header compiled with errors
"Compile_Error"=>6,
# Invalid input ABI dump
"Invalid_Dump"=>7,
# Incompatible version of ABI dump
"Dump_Version"=>8,
# Cannot find a module
"Module_Error"=>9,
# Empty intersection between
# headers and shared objects
"Empty_Intersection"=>10,
# Empty set of symbols in headers
"Empty_Set"=>11
);
sub exitStatus($$)
{
my ($Code, $Msg) = @_;
printMsg("ERROR", $Msg);
exit($ERROR_CODE{$Code});
}
sub getErrorCode($) {
return $ERROR_CODE{$_[0]};
}
sub getCodeError($)
{
my %CODE_ERROR = reverse(%ERROR_CODE);
return $CODE_ERROR{$_[0]};
}
sub printMsg($$)
{
my ($Type, $Msg) = @_;
if($Type!~/\AINFO/) {
$Msg = $Type.": ".$Msg;
}
if($Type!~/_C\Z/) {
$Msg .= "\n";
}
if($In::Opt{"Quiet"})
{ # --quiet option
appendFile($In::Opt{"DefaultLog"}, $Msg);
}
else
{
if($Type eq "ERROR") {
print STDERR $Msg;
}
else {
print $Msg;
}
}
}
sub initLogging($)
{
my $LVer = $_[0];
# create log directory
my ($LogDir, $LogFile) = ("logs/".$In::Opt{"TargetLib"}."/".$In::Desc{$LVer}{"Version"}, "log.txt");
if(my $LogPath = $In::Desc{$LVer}{"OutputLogPath"})
{ # user-defined by -log-path option
($LogDir, $LogFile) = sepPath($LogPath);
}
if($In::Opt{"LogMode"} ne "n") {
mkpath($LogDir);
}
$LOG_PATH{$LVer} = join_P(getAbsPath($LogDir), $LogFile);
if($In::Opt{"Debug"}) {
initDebugging($LVer);
}
resetLogging($LVer);
resetDebugging($LVer);
}
sub initDebugging($)
{
my $LVer = $_[0];
# debug directory
$DEBUG_DIR{$LVer} = "debug/".$In::Opt{"TargetLib"}."/".$In::Desc{$LVer}{"Version"};
}
sub getDebugDir($) {
return $DEBUG_DIR{$_[0]};
}
sub getExtraDir($) {
return $DEBUG_DIR{$_[0]}."/extra-info";
}
sub writeLog($$)
{
my ($LVer, $Msg) = @_;
if($In::Opt{"LogMode"} ne "n") {
appendFile($LOG_PATH{$LVer}, $Msg);
}
}
sub resetLogging($)
{
my $LVer = $_[0];
if($In::Opt{"LogMode"}!~/a|n/)
{ # remove old log
unlink($LOG_PATH{$LVer});
}
}
sub resetDebugging($)
{
my $LVer = $_[0];
if($In::Opt{"Debug"})
{
if(-d $DEBUG_DIR{$LVer})
{
rmtree($DEBUG_DIR{$LVer});
}
mkpath($DEBUG_DIR{$LVer});
}
}
sub printErrorLog($)
{
my $LVer = $_[0];
if($In::Opt{"LogMode"} ne "n") {
printMsg("ERROR", "see log for details:\n ".$LOG_PATH{$LVer}."\n");
}
}
return 1;
|