Changeset 2666 for devel


Ignore:
Timestamp:
Jun 24, 2010, 2:22:04 AM (9 years ago)
Author:
bruno
Message:

r3927@localhost: bruno | 2010-06-23 02:13:19 +0200

  • Improved version for log file mngt
Location:
devel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • devel/mr/lib/MondoRescue/Base.pm

    r2659 r2666  
    102102
    103103my $code = shift;
    104 my $msg = shift || "";
     104my $msg = shift;
    105105
    106106if (defined $msg) {
    107107    pb_log($pbdebug,$msg);
     108}
     109# CLoses log
     110if (defined $mr->{'logdesc'}) {
     111    close($mr->{'logdesc'});
    108112}
    109113die "ERROR returned\n" if ($code < 0);
  • devel/mrmini/etc/mrmini.conf

    r2659 r2666  
    9393# Location of the logfile
    9494#
    95 mr_log_file mrmini = /var/log/mrmini.log
     95mr_logfile mrmini = /var/log/mrmini.log
    9696
    9797#
  • devel/mrmini/lib/MondoRescue/Mini/Base.pm

    r2659 r2666  
    5151sub mr_mini_main {
    5252
    53     my $logfile = shift || undef;
    5453#
    5554# Configuration parameters
     
    6564($mr->{'boot_size'},$mr->{'boot_cd'},$mr->{'boot_usb'},$mr->{'boot_tape'},$mr->{'kernel'},$mr->{'fstab'}) =  mr_conf_get("mr_boot_size","mr_boot_cd","mr_boot_usb","mr_boot_tape","mr_kernel","mr_fstab");
    6665($mr->{'tape_mods'},$mr->{'scsi_mods'},$mr->{'ide_mods'},$mr->{'pcmcia_mods'},$mr->{'usb_mods'},$mr->{'net_mods'},$mr->{'cdrom_mods'},$mr->{'deny_mods'},$mr->{'force_mods'}) =  mr_conf_get("mr_tape_mods","mr_scsi_mods","mr_ide_mods","mr_pcmcia_mods","mr_usb_mods","mr_net_mods","mr_cdrom_mods","mr_extra_mods","mr_deny_mods","mr_force_mods");
    67 ($mr->{'log_file'},$mr->{'cache_dir'},$mr->{'boot_msg'},$mr->{'burn_cmd'},$mr->{'burn_opt'}) = mr_conf_get("mr_log_file","mr_cache_dir","mr_boot_msg","mr_burn_cmd","mr_burn_opt");
     66($mr->{'cache_dir'},$mr->{'boot_msg'},$mr->{'burn_cmd'},$mr->{'burn_opt'}) = mr_conf_get("mr_cache_dir","mr_boot_msg","mr_burn_cmd","mr_burn_opt");
    6867
    6968#
    7069# Manage log file
    7170#
    72 $logfile = $mr->{'log_file'} if (not defined $logfile);
    73 
    74 open(pbLOG,"> $logfile") || die "Unable to log to $logfile: $!";
    75 $pbLOG = \*pbLOG;
     71$pbLOG = $mr->{'logdesc'};
    7672$pbdebug = 1  if ($pbdebug == -1);
    7773pb_log_init($pbdebug, $pbLOG);
    7874
    79 pb_log(0,"$ENV{'PBPKG'} start date: $mr->{'start_date'}\n");
    80 pb_log(0,"-------------------------------------\n");
    81 pb_log(0,"$ENV{'PBPKG'} v$mr->{'version'}\n");
     75my $sep = "-----------------------------------------------\n";
     76
     77pb_log(0,"$ENV{'PBPKG'} v$mr->{'version'} start date: $mr->{'start_date'}\n");
     78pb_log(0,$sep);
    8279pb_log(0,"$ARCH architecture detected\n");
    8380pb_log(0,"$ENV{'PBPKG'} called with the following arguments: ".join(" ",@ARGV)."\n");
    84 pb_log(0,"-------------------------------------\n");
    85 pb_log(0,"MONDO_CACHE: $ENV{'MONDO_CACHE'}\n") if (defined $ENV{'MONDO_CACHE'});
    86 pb_log(0,"MRMINI CONFDIR: $mr->{'confdir'}\n");
    87 pb_log(0,"MRMINI SBIN: $mr->{'install_dir'}/sbin\n");
     81pb_log(0,$sep);
     82pb_log(1,"CONFDIR: $mr->{'confdir'}\n");
     83pb_log(1,"SBIN: $mr->{'install_dir'}/sbin\n");
    8884if (-r "$ENV{'HOME'}/.mondorescuerc") {
    89     pb_log(0,"-------------------------------------\n");
     85    pb_log(0,$sep);
    9086    pb_log(0,"Conf file $ENV{'HOME'}/.mondorescuerc\n");
    91     pb_display_file("$ENV{'HOME'}/.mondorescuerc");
     87    pb_display_file("$ENV{'HOME'}/.mondorescuerc",$pbLOG);
    9288}
    9389if (-r "$mr->{'confdir'}/mondorescue.conf") {
    94     pb_log(0,"-------------------------------------\n");
     90    pb_log(0,$sep);
    9591    pb_log(0,"Conf file $mr->{'confdir'}/mondorescue.conf\n");
    96     pb_display_file("$mr->{'confdir'}/mondorescue.conf");
     92    pb_display_file("$mr->{'confdir'}/mondorescue.conf",$pbLOG);
    9793}
    98 pb_log(0,"-------------------------------------\n");
     94pb_log(0,$sep);
    9995
    10096#
     
    113109
    114110pb_log(0,"LVM $lvmver command set to $lvmcmd\n");
    115 pb_log(0,"-------------------------------------\n");
    116 close(pbLOG);
     111pb_log(0,$sep);
    117112}
  • devel/mrmini/sbin/mrmini

    r2659 r2666  
    210210my $logfile = undef;
    211211if (defined $opts{'l'}) {
     212    # Log file forced externally
    212213    $logfile = $opts{'l'};
     214} elsif ($pbdebug ge 1) {
     215    # Log file forced internally to default value as we are in debug mode
     216    ($logfile) =  mr_conf_get("mr_logfile");
     217}
     218
     219if (defined $logfile) {
     220    open(pbLOG,"> $logfile") || die "Unable to log to $logfile: $!";
     221    $mr->{'logdesc'} = \*pbLOG;
     222} else {
     223    $mr->{'logdesc'} = undef;
    213224}
    214225
     
    217228#
    218229pb_temp_init();
    219 mr_mini_main($logfile);
     230mr_mini_main();
    220231mr_exit(0);
Note: See TracChangeset for help on using the changeset viewer.