Changeset 495 in ProjectBuilder for devel/pb-modules
- Timestamp:
- Jul 10, 2008, 11:36:18 AM (17 years ago)
- Location:
- devel/pb-modules
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/bin/pbdistrocheck
r423 r495 19 19 GetOptions("verbose|v+" => \$opts{'v'}); 20 20 if (defined $opts{'v'}) { 21 $ debug = $opts{'v'};21 $pbdebug = $opts{'v'}; 22 22 } 23 23 if (defined $opts{'l'}) { 24 open( LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";25 $ LOG = \*LOG;26 $ debug = 0 if ($debug == -1);24 open(pbLOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!"; 25 $pbLOG = \*pbLOG; 26 $pbdebug = 0 if ($pbdebug == -1); 27 27 } 28 pb_log_init($ debug, $LOG);28 pb_log_init($pbdebug, $pbLOG); 29 29 30 30 my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init(); -
devel/pb-modules/lib/ProjectBuilder/Base.pm
r482 r495 20 20 use Pod::Usage; 21 21 use English; 22 use locale; 23 use Locale::gettext; 24 use POSIX qw(setlocale); 22 25 23 26 # Inherit from the "Exporter" module which handles exporting functions. … … 28 31 # any code which uses this module. 29 32 30 our $debug = 0; # Global debug level 31 our $LOG = \*STDOUT; # File descriptor of the log file 32 our $synmsg = "Error"; # Global error message 33 our $pbdebug = 0; # Global debug level 34 our $pbLOG = \*STDOUT; # File descriptor of the log file 35 our $pbsynmsg = "Error"; # Global error message 36 our $pbdisplaytype = "text"; 37 # default display mode for messages 38 our $pblocale = "C"; 33 39 34 40 our @ISA = qw(Exporter); 35 our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_ get_uri pb_get_content pb_display_file pb_syntax_init pb_syntax pb_temp_init $debug $LOG);41 our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_display pb_display_init pb_get_uri pb_get_content pb_display_file pb_syntax_init pb_syntax pb_temp_init $pbdebug $pbLOG $pbdisplaytype $pblocale); 36 42 37 43 =pod … … 79 85 pb_log_init(2,\*STDOUT); 80 86 pb_log(1,"Message to print\n"); 87 88 # 89 # Manages prints of the program 90 # 91 pb_display_init("text","fr_FR:UTF-8"); 92 pb_display("Message to print\n"); 81 93 82 94 # … … 220 232 sub pb_log_init { 221 233 222 $ debug = shift || 0;223 $ LOG = shift || \*STDOUT;224 pb_log(1,"Debug value: $ debug\n");234 $pbdebug = shift || 0; 235 $pbLOG = shift || \*STDOUT; 236 pb_log(1,"Debug value: $pbdebug\n"); 225 237 226 238 } … … 249 261 my $msg = shift; 250 262 251 print $LOG "$msg" if ($dlevel <= $debug); 263 print $pbLOG "$msg" if ($dlevel <= $pbdebug); 264 } 265 266 267 =item B<pb_display_init> 268 269 This function initializes the environment used by the pb_display function. 270 271 The first parameter is the type of display which will be used. Could be "text", "web", "newt",... 272 The second parameter is the loacle to be used. 273 274 The call to B<pb_display_init> is typically done after getting a parameter on the CLI indicating the locale used or the type of interface to report messages to. 275 276 =cut 277 278 sub pb_display_init { 279 280 $pbdisplaytype = shift || "text"; 281 $pblocale = shift || "C"; 282 283 setlocale(LC_ALL, $pblocale); 284 pb_log(1,"Using $pbdisplaytype interface with $pblocale locale\n"); 285 286 if ($pbdisplaytype =~ /text/) { 287 } elsif ($pbdisplaytype = /newt/) { 288 } else { 289 die "display system $pbdisplaytype unsupported"; 290 } 291 } 292 293 =item B<pb_display> 294 295 This function prints the messages passed as parameter using the configuration set up with the B<pb_display_init> function. 296 297 Here is a usage example: 298 299 pb_display_init("text","fr_FR.UTF-8"); 300 pb_display("Hello World\n"); 301 302 will print: 303 304 Bonjour Monde 305 306 =cut 307 308 sub pb_display { 309 310 my $msg = shift; 311 312 if ($pbdisplaytype =~ /text/) { 313 print STDOUT gettext($msg); 314 } 252 315 } 253 316 … … 298 361 sub pb_syntax_init { 299 362 300 $ synmsg = shift || "Error";363 $pbsynmsg = shift || "Error"; 301 364 } 302 365 … … 320 383 $filehandle = \*STDOUT if ($exit_status == 0); 321 384 322 pod2usage( { -message => $ synmsg,385 pod2usage( { -message => $pbsynmsg, 323 386 -exitval => $exit_status , 324 387 -verbose => $verbose_level,
Note:
See TracChangeset
for help on using the changeset viewer.