diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-09-15 08:53:55 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-09-15 08:53:55 +0000 |
commit | df46fbe8d506057b23c6d0fd322cfa251ae372ec (patch) | |
tree | 87e842a5a84780834b4d33f39a20d913a962f17f /src | |
parent | c11fe60beecd27709c31a0facecfaad5bbdb717b (diff) |
Fixed logging level (especially for robots.txt rules)
(manual backport of r867)
Diffstat (limited to 'src')
-rw-r--r-- | src/htsback.c | 14 | ||||
-rw-r--r-- | src/htscore.c | 10 | ||||
-rw-r--r-- | src/htscoremain.c | 13 | ||||
-rw-r--r-- | src/htslib.c | 27 | ||||
-rw-r--r-- | src/htsopt.h | 10 | ||||
-rw-r--r-- | src/httrack-library.h | 10 |
6 files changed, 37 insertions, 47 deletions
diff --git a/src/htsback.c b/src/htsback.c index e7d64e5..d026e7a 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -202,13 +202,13 @@ static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, freet(itemback); itemback = NULL; } - hts_log_print(opt, LOG_INFO | LOG_ERRNO, + hts_log_print(opt, LOG_WARNING | LOG_ERRNO, "engine: warning: unserialize error for %s%s (%s)", adr, fil, sav); } fclose(fp); } else { - hts_log_print(opt, LOG_INFO | LOG_ERRNO, + hts_log_print(opt, LOG_WARNING | LOG_ERRNO, "engine: warning: unserialize error for %s%s (%s), file disappeared", adr, fil, sav); } @@ -231,7 +231,7 @@ static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, back_set_locked(sback, q); /* locked */ return q; } else { - hts_log_print(opt, LOG_INFO, + hts_log_print(opt, LOG_WARNING, "engine: warning: unserialize error for %s%s (%s): no more space to wakeup frozen slots", adr, fil, sav); } @@ -300,7 +300,7 @@ int back_cleanup_background(httrackp * opt, cache_back * cache, } /* Security check */ if (fexist_utf8(filename)) { - hts_log_print(opt, LOG_INFO, + hts_log_print(opt, LOG_WARNING, "engine: warning: temporary file %s already exists", filename); } @@ -313,13 +313,13 @@ int back_cleanup_background(httrackp * opt, cache_back * cache, nclean++; back_clear_entry(&back[i]); /* entry is now recycled */ } else { - hts_log_print(opt, LOG_INFO | LOG_ERRNO, + hts_log_print(opt, LOG_WARNING | LOG_ERRNO, "engine: warning: serialize error for %s%s to %s: write error", back[i].url_adr, back[i].url_fil, filename); } fclose(fp); } else { - hts_log_print(opt, LOG_INFO | LOG_ERRNO, + hts_log_print(opt, LOG_WARNING | LOG_ERRNO, "engine: warning: serialize error for %s%s to %s: open error (%s, %s)", back[i].url_adr, back[i].url_fil, filename, dir_exists(filename) ? "directory exists" : @@ -330,7 +330,7 @@ int back_cleanup_background(httrackp * opt, cache_back * cache, if (filename != NULL) free(filename); } else { - hts_log_print(opt, LOG_INFO | LOG_ERRNO, + hts_log_print(opt, LOG_WARNING | LOG_ERRNO, "engine: warning: serialize error for %s%s to %s: memory full", back[i].url_adr, back[i].url_fil, filename); } diff --git a/src/htscore.c b/src/htscore.c index d996ffe..8f0eeeb 100644 --- a/src/htscore.c +++ b/src/htscore.c @@ -536,7 +536,7 @@ int httpmirror(char *url1, httrackp * opt) { __LINE__); hts_log_print(opt, LOG_PANIC, "Too many filters, giving up..(>%d)", filptr); - hts_log_print(opt, LOG_INFO, + hts_log_print(opt, LOG_NOTICE, "To avoid that: use #F option for more filters (example: -#F5000)"); XH_extuninit; return 0; @@ -615,7 +615,7 @@ int httpmirror(char *url1, httrackp * opt) { } } // fclose(fp); - hts_log_print(opt, LOG_INFO, "%d links added from %s", n, + hts_log_print(opt, LOG_NOTICE, "%d links added from %s", n, StringBuff(opt->filelist)); // Free buffer @@ -1710,7 +1710,7 @@ int httpmirror(char *url1, httrackp * opt) { } #ifdef IGNORE_RESTRICTIVE_ROBOTS else { - hts_log_print(opt, LOG_INFO, + hts_log_print(opt, LOG_NOTICE, "Note: %s robots.txt rules are too restrictive, ignoring /", urladr); } @@ -1724,7 +1724,7 @@ int httpmirror(char *url1, httrackp * opt) { hts_log_print(opt, LOG_INFO, "Note: robots.txt forbidden links for %s are: %s", urladr, infobuff); - hts_log_print(opt, LOG_INFO, + hts_log_print(opt, LOG_NOTICE, "Note: due to %s remote robots.txt rules, links beginning with these path will be forbidden: %s (see in the options to disable this)", urladr, infobuff); } @@ -1974,7 +1974,7 @@ int httpmirror(char *url1, httrackp * opt) { if ((HTS_STAT.stat_files <= 0) && (HTS_STAT.HTS_TOTAL_RECV < 32768) /* should be fine */ ) { - hts_log_print(opt, LOG_INFO, + hts_log_print(opt, LOG_NOTICE, "No data seems to have been transferred during this session! : restoring previous one!"); XH_uninit; if ((fexist diff --git a/src/htscoremain.c b/src/htscoremain.c index 5545b04..55dcb80 100644 --- a/src/htscoremain.c +++ b/src/htscoremain.c @@ -1165,6 +1165,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) { // case 'Q': httrack_logmode = 0; + opt->debug = LOG_NOTICE; break; case 'v': httrack_logmode = 1; @@ -1385,17 +1386,17 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) { break; // case 'z': - if (opt->debug >= 2) { - opt->debug = 3; /* -Zz */ + if (opt->debug > LOG_INFO) { + opt->debug = LOG_DEBUG; /* -Zz */ } else { - opt->debug = 1; + opt->debug = LOG_INFO; } break; // petit debug case 'Z': - if (opt->debug >= 1) { - opt->debug = 3; /* -Zz */ + if (opt->debug >= LOG_DEBUG) { + opt->debug = LOG_TRACE; /* -Zz */ } else { - opt->debug = 2; + opt->debug = LOG_DEBUG; } break; // GROS debug // diff --git a/src/htslib.c b/src/htslib.c index d731d01..b52756a 100644 --- a/src/htslib.c +++ b/src/htslib.c @@ -5225,35 +5225,24 @@ HTSEXT_API void hts_log_print(httrackp * opt, int type, const char *format, ...) va_list args; const int save_errno = errno; const char *s_type = "unknown"; + const int level = type & 0xff; - switch (type & 0xff) { + // Check log level + if (opt->debug < level) { + return; + } + + switch (level) { case LOG_TRACE: - // check verbosity - if (opt->debug < 3) { - return; - } s_type = "trace"; break; case LOG_DEBUG: - // check verbosity - if (opt->debug < 2) { - return; - } s_type = "debug"; break; case LOG_INFO: - // check verbosity - if (opt->debug < 1) { - return; - } s_type = "info"; break; case LOG_NOTICE: - // check verbosity - if (opt->debug < 1) { - return; - } - /* nobreak; */ case LOG_WARNING: s_type = "warning"; break; @@ -5410,7 +5399,7 @@ HTSEXT_API httrackp *hts_create_opt(void) { opt->seeker = 1; // down opt->urlmode = 2; // relatif par défaut opt->no_type_change = 0; // change file types - opt->debug = 0; // pas de débug en plus + opt->debug = LOG_NOTICE; // small log opt->getmode = 3; // linear scan opt->maxsite = -1; // taille max site (aucune) opt->maxfile_nonhtml = -1; // taille max fichier non html diff --git a/src/htsopt.h b/src/htsopt.h index 86da4cf..060f00d 100644 --- a/src/htsopt.h +++ b/src/htsopt.h @@ -172,12 +172,12 @@ typedef struct lien_url lien_url; #define HTS_DEF_DEFSTRUCT_hts_log_type typedef enum hts_log_type { LOG_TRACE, - LOG_DEBUG, - LOG_INFO, - LOG_NOTICE, - LOG_WARNING, - LOG_ERROR, LOG_PANIC, + LOG_ERROR, + LOG_WARNING, + LOG_NOTICE, + LOG_INFO, + LOG_DEBUG, LOG_ERRNO = 1 << 8 } hts_log_type; #endif diff --git a/src/httrack-library.h b/src/httrack-library.h index a3e7138..47b44be 100644 --- a/src/httrack-library.h +++ b/src/httrack-library.h @@ -47,12 +47,12 @@ typedef struct strc_int2bytes2 strc_int2bytes2; #define HTS_DEF_DEFSTRUCT_hts_log_type typedef enum hts_log_type { LOG_TRACE, - LOG_DEBUG, - LOG_INFO, - LOG_NOTICE, - LOG_WARNING, - LOG_ERROR, LOG_PANIC, + LOG_ERROR, + LOG_WARNING, + LOG_NOTICE, + LOG_INFO, + LOG_DEBUG, LOG_ERRNO = 1 << 8 } hts_log_type; #endif |