Stephane Chauveau wrote:
> For Nicolas,
>
> The easiest way to log the errors is to redirect the error output stream (number 2) to a file.
>
> For example, you can run the script as follow
>
> /usr/local/bin/category-filter.pl 2> /tmp/category-filter.log
>
> or if you want to APPEND to the log file, use a double >> instead
>
> /usr/local/bin/category-filter.pl 2>> /tmp/category-filter.log
>
> The alternative is to modify the perl script itself.
>
> Add the following line at the beginning of the script to open the log file in append mode:
>
> open(LOG, ">>", "/tmp/category-filter.log") or die "Can't open LOG file: $!";
>
> Then clone the 'print STDERR' line and replace 'STDERR' by 'LOG':
>
> print STDERR "Warning: Unmanaged category: '$a'\n" ;
> print LOG "Warning: Unmanaged category: '$a'\n" ;
>
> If you do not want to repeat the same error hundreds or thousands of times, you can memorize the wrong categories as follow to emit a single error for each.
>
> At the beginning of the script, create an empty map:
>
> my %BAD ;
>
> Then modify the prints to STDERR and LOG as follow
>
> if ( ! exists $BAD{$a} ) {
> print STDERR "Warning: Unmanaged category: '$a'\n" ;
> print LOG "Warning: Unmanaged category: '$a'\n" ;
> # Record in BAD map so next error won't produce a message
> $BAD{$a} = 1 ;
> }
Hi Stephane,
I´m trying to implement your script with the BAD map now because I´m started to get more Unmanaged categories from some time ago since I´ve included more grabbers to fill my .xml file.
The problem is that I´m doing something wrong since I´m recieving this output:
Missing right curly or square bracket at /share/CACHEDEV1_DATA/homes/nico/wg++/categorias/cambia_categorias.pl line 330, at end of line
syntax error at /share/CACHEDEV1_DATA/homes/nico/wg++/categorias/cambia_categorias.pl line 330, at EOF
Execution of /share/CACHEDEV1_DATA/homes/nico/wg++/categorias/cambia_categorias.pl aborted due to compilation errors.
I´ve tried some things but without success. Check the script attached in this post to review it and comment me what is wrong.
Thank you very much