on error pages if used.
</verb>
+ <tag>debug_options rotate=</tag>
+ <p>New parameter rotate=N to control number of cache.log rotations independent of other logs.
+
+
<tag>external_acl_type</tag>
<p>New options 'ipv4' and 'ipv6' are added to set the IPv4/v6 protocol between squid and its helpers.
Please be aware of some limits to these options. These options only affet the transport protocol used
<tag>https_port intercept sslbump connection-auth[=on|off]</tag>
<p>New port options. see http_port.
+ <tag>logfile_rotate</tag>
+ <p>No longer controls cache.log rotation. Use debug_options rotate=N instead.
+
<tag>maximum_object_size_in_memory</tag>
<p>Default size limit increased to 512KB.
<p>Method names now accepted. Replacing the old magic numbers.
'1' becomes 'gre' and '2' becomes 'l2'
-
</descrip>
#define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
#endif
+/* context-based debugging, the actual type is subject to change */
+typedef int Ctx;
+
/* defined debug section limits */
#define MAX_DEBUG_SECTIONS 100
{
public:
+ static char *debugOptions;
+ static char *cache_log;
+ static int rotateNumber;
static int Levels[MAX_DEBUG_SECTIONS];
static int level;
+ static int override_X;
+ static int log_stderr;
+ static bool log_syslog;
+
static std::ostream &getDebugOut();
static void finishDebug();
static void parseOptions(char const *);
if (!Config.chroot_dir) {
leave_suid();
setUmask(Config.umask);
- _db_init(Config.Log.log, Config.debugOptions);
+ _db_init(Debug::cache_log, Debug::debugOptions);
enter_suid();
}
else
Config.appendDomainLen = 0;
- safe_free(debug_options)
- debug_options = xstrdup(Config.debugOptions);
-
if (Config.retry.maxtries > 10)
fatal("maximum_single_addr_tries cannot be larger than 10");
logging will also not be accounted for in performance counters.
DOC_END
-NAME: cache_log
-TYPE: string
-DEFAULT: none
-DEFAULT_IF_NONE: @DEFAULT_CACHE_LOG@
-LOC: Config.Log.log
-DOC_START
- Cache logging file. This is where general information about
- your cache's behavior goes. You can increase the amount of data
- logged to this file with the "debug_options" tag below.
-DOC_END
-
NAME: cache_store_log
TYPE: string
DEFAULT: none
purposes, so -k rotate uses another signal. It is best to get
in the habit of using 'squid -k rotate' instead of 'kill -USR1
<pid>'.
+
+ Note, from Squid-3.1 this option has no effect on the cache.log,
+ that log can be rotated separately by using debug_options
DOC_END
NAME: emulate_httpd_log
A filename to write the process-id to. To disable, enter "none".
DOC_END
-NAME: debug_options
-TYPE: eol
-DEFAULT: ALL,1
-LOC: Config.debugOptions
-DOC_START
- Logging options are set as section,level where each source file
- is assigned a unique section. Lower levels result in less
- output, Full debugging (level 9) can result in a very large
- log file, so be careful. The magic word "ALL" sets debugging
- levels for all sections. We recommend normally running with
- "ALL,1".
-DOC_END
-
NAME: log_fqdn
COMMENT: on|off
TYPE: onoff
To disable, enter "none".
DOC_END
+COMMENT_START
+ OPTIONS FOR TROUBLESHOOTING
+ -----------------------------------------------------------------------------
+COMMENT_END
+
+NAME: cache_log
+TYPE: string
+DEFAULT: none
+DEFAULT_IF_NONE: @DEFAULT_CACHE_LOG@
+LOC: Debug::cache_log
+DOC_START
+ Cache logging file. This is where general information about
+ your cache's behavior goes. You can increase the amount of data
+ logged to this file and how often its rotated with "debug_options"
+DOC_END
+
+NAME: debug_options
+TYPE: eol
+DEFAULT: rotate=1 ALL,1
+LOC: Debug::debugOptions
+DOC_START
+ Logging options are set as section,level where each source file
+ is assigned a unique section. Lower levels result in less
+ output, Full debugging (level 9) can result in a very large
+ log file, so be careful.
+
+ The magic word "ALL" sets debugging levels for all sections.
+ We recommend normally running with "ALL,1".
+
+ The rotate= option can be increased to keep more of these logs.
+ For most uses a single log should be enough to monitor current
+ events affecting Squid.
+DOC_END
+
+NAME: coredump_dir
+TYPE: string
+LOC: Config.coredump_dir
+DEFAULT: none
+DEFAULT_IF_NONE: none
+DOC_START
+ By default Squid leaves core files in the directory from where
+ it was started. If you set 'coredump_dir' to a directory
+ that exists, Squid will chdir() to that directory at startup
+ and coredump files will be left there.
+
+NOCOMMENT_START
+# Leave coredumps in the first cache dir
+coredump_dir @DEFAULT_SWAP_DIR@
+NOCOMMENT_END
+DOC_END
+
+
COMMENT_START
OPTIONS FOR FTP GATEWAYING
-----------------------------------------------------------------------------
violation.
DOC_END
-NAME: coredump_dir
-TYPE: string
-LOC: Config.coredump_dir
-DEFAULT: none
-DEFAULT_IF_NONE: none
-DOC_START
- By default Squid leaves core files in the directory from where
- it was started. If you set 'coredump_dir' to a directory
- that exists, Squid will chdir() to that directory at startup
- and coredump files will be left there.
-
-NOCOMMENT_START
-# Leave coredumps in the first cache dir
-coredump_dir @DEFAULT_SWAP_DIR@
-NOCOMMENT_END
-DOC_END
-
NAME: chroot
TYPE: string
LOC: Config.chroot_dir
#include "config.h"
#include "Debug.h"
#include "SquidTime.h"
+#include "util.h"
-/* for Config */
-#include "structs.h"
+/* for shutting_down flag in xassert() */
+#include "globals.h"
+/* cope with no squid.h */
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 256
+#endif
+
+char *Debug::debugOptions = NULL;
+int Debug::override_X = 0;
+int Debug::log_stderr = -1;
+bool Debug::log_syslog = false;
int Debug::Levels[MAX_DEBUG_SECTIONS];
int Debug::level;
+char *Debug::cache_log = NULL;
+int Debug::rotateNumber = 1;
FILE *debug_log = NULL;
static char *debug_log_file = NULL;
static int Ctx_Lock = 0;
void
_db_print(const char *format,...)
{
- LOCAL_ARRAY(char, f, BUFSIZ);
+ char f[BUFSIZ]; f[0]='\0';
va_list args1;
va_list args2;
va_list args3;
ctx_print();
vfprintf(debug_log, format, args);
-
-//*AYJ:*/ if (!Config.onoff.buffered_logs)
fflush(debug_log);
}
static void
_db_print_stderr(const char *format, va_list args)
{
- if (opt_debug_stderr < Debug::level)
+ if (Debug::log_stderr < Debug::level)
return;
if (debug_log == stderr)
static void
_db_print_syslog(const char *format, va_list args)
{
- LOCAL_ARRAY(char, tmpbuf, BUFSIZ);
/* level 0,1 go to syslog */
if (Debug::level > 1)
return;
- if (0 == opt_syslog_enable)
+ if (!Debug::log_syslog)
return;
+ char tmpbuf[BUFSIZ];
tmpbuf[0] = '\0';
vsnprintf(tmpbuf, BUFSIZ, format, args);
syslog(Debug::level == 0 ? LOG_WARNING : LOG_NOTICE, "%s", tmpbuf);
}
-
#endif /* HAVE_SYSLOG */
static void
int l = 0;
int i;
- if (!strncasecmp(arg, "ALL", 3)) {
+ if (!strncasecmp(arg, "rotate=", 7)) {
+ arg += 7;
+ Debug::rotateNumber = atoi(arg);
+ return;
+ } else if (!strncasecmp(arg, "ALL", 3)) {
s = -1;
arg += 4;
} else {
s = atoi(arg);
-
while (*arg && *arg++ != ',');
}
void
_db_set_syslog(const char *facility)
{
- opt_syslog_enable = 1;
+ Debug::log_syslog = true;
+
#ifdef LOG_LOCAL4
#ifdef LOG_DAEMON
#else
syslog_facility = LOG_LOCAL4;
-#endif
+#endif /* LOG_DAEMON */
if (facility) {
if (facility)
fprintf(stderr, "syslog facility type not supported on your system\n");
-#endif
+#endif /* LOG_LOCAL4 */
}
#endif
char *p = NULL;
char *s = NULL;
- if (Config.onoff.debug_override_X) {
+ if (override_X) {
debugs(0, 9, "command-line -X overrides: " << options);
return;
}
#if HAVE_SYSLOG && defined(LOG_LOCAL4)
- if (opt_syslog_enable)
+ if (Debug::log_syslog)
openlog(APP_SHORTNAME, LOG_PID | LOG_NDELAY | LOG_CONS, syslog_facility);
#endif /* HAVE_SYSLOG */
void
_db_rotate_log(void)
{
- int i;
- LOCAL_ARRAY(char, from, MAXPATHLEN);
- LOCAL_ARRAY(char, to, MAXPATHLEN);
-#ifdef S_ISREG
-
- struct stat sb;
-#endif
-
if (debug_log_file == NULL)
return;
#ifdef S_ISREG
-
+ struct stat sb;
if (stat(debug_log_file, &sb) == 0)
if (S_ISREG(sb.st_mode) == 0)
return;
-
#endif
+ char from[MAXPATHLEN];
+ from[0] = '\0';
+
+ char to[MAXPATHLEN];
+ to[0] = '\0';
+
/*
* NOTE: we cannot use xrename here without having it in a
* separate file -- tools.c has too many dependencies to be
* used everywhere debug.c is used.
*/
/* Rotate numbers 0 through N up one */
- for (i = Config.Log.rotateNumber; i > 1;) {
+ for (int i = Debug::rotateNumber; i > 1;) {
i--;
snprintf(from, MAXPATHLEN, "%s.%d", debug_log_file, i - 1);
snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i);
#ifdef _SQUID_MSWIN_
-
remove
(to);
-
#endif
-
rename(from, to);
}
#ifdef _SQUID_MSWIN_
if (debug_log != stderr)
fclose(debug_log);
-
#endif
/* Rotate the current log to .0 */
- if (Config.Log.rotateNumber > 0) {
+ if (Debug::rotateNumber > 0) {
snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0);
#ifdef _SQUID_MSWIN_
-
remove
(to);
-
#endif
-
rename(debug_log_file, to);
}
/* Close and reopen the log. It may have been renamed "manually"
* before HUP'ing us. */
if (debug_log != stderr)
- debugOpenLog(Config.Log.log);
+ debugOpenLog(Debug::cache_log);
}
static const char *
extern const char *dns_error_message; /* NULL */
extern const char *log_tags[];
extern char tmp_error_buf[ERROR_BUF_SZ];
- extern char *volatile debug_options; /* NULL */
extern char ThisCache[RFC2181_MAXHOSTNAMELEN << 1];
extern char ThisCache2[RFC2181_MAXHOSTNAMELEN << 1];
extern char config_input_line[BUFSIZ];
//DEAD extern int icmp_sock; /* -1 */
extern int neighbors_do_private_keys; /* 1 */
extern int opt_catch_signals; /* 1 */
- extern int opt_debug_stderr; /* -1 */
extern int opt_foreground_rebuild; /* 0 */
extern char *opt_forwarded_for; /* NULL */
extern int opt_reload_hit_only; /* 0 */
-#if HAVE_SYSLOG
-
- extern int opt_syslog_enable; /* 0 */
-#endif
extern int opt_udp_hit_obj; /* 0 */
extern int opt_create_swap_dirs; /* 0 */
#if HAVE_PUTENV
char *env_str;
int tmp_s;
- env_str = (char *)xcalloc((tmp_s = strlen(Config.debugOptions) + 32), 1);
- snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Config.debugOptions);
+ env_str = (char *)xcalloc((tmp_s = strlen(Debug::debugOptions) + 32), 1);
+ snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Debug::debugOptions);
putenv(env_str);
#endif
}
#if HAVE_PUTENV
char *env_str;
int tmp_s;
- env_str = (char *)xcalloc((tmp_s = strlen(Config.debugOptions) + 32), 1);
- snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Config.debugOptions);
+ env_str = (char *)xcalloc((tmp_s = strlen(Debug::debugOptions) + 32), 1);
+ snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Debug::debugOptions);
putenv(env_str);
#endif
}
case 'X':
/** \par X
* Force full debugging */
- Debug::parseOptions("debug_options ALL,9");
- Config.onoff.debug_override_X = 1;
+ Debug::parseOptions("rotate=0 ALL,9");
+ Debug::override_X = 1;
sigusr2_handle(SIGUSR2);
break;
case 'd':
/** \par d
- * Set global option opt_debug_stderr to the number given follwoign the option */
- opt_debug_stderr = atoi(optarg);
+ * Set global option Debug::log_stderr to the number given follwoign the option */
+ Debug::log_stderr = atoi(optarg);
break;
case 'f':
case 'z':
/** \par z
- * Set global option opt_debug_stderr and opt_create_swap_dirs */
- opt_debug_stderr = 1;
-
+ * Set global option Debug::log_stderr and opt_create_swap_dirs */
+ Debug::log_stderr = 1;
opt_create_swap_dirs = 1;
-
break;
case 'h':
setUmask(Config.umask);
Mem::Report();
setEffectiveUser();
- _db_init(Config.Log.log, Config.debugOptions);
+ _db_init(Debug::cache_log, Debug::debugOptions);
ipcache_restart(); /* clear stuck entries */
authenticateUserCacheRestart(); /* clear stuck ACL entries */
fqdncache_restart(); /* sigh, fqdncache too */
if (icpPortNumOverride != 1)
Config.Port.icp = (u_short) icpPortNumOverride;
- _db_init(Config.Log.log, Config.debugOptions);
+ _db_init(Debug::cache_log, Debug::debugOptions);
- fd_open(fileno(debug_log), FD_LOG, Config.Log.log);
+ fd_open(fileno(debug_log), FD_LOG, Debug::cache_log);
#if MEM_GEN_TRACE
dup2(nullfd, 0);
- if (opt_debug_stderr < 0) {
+ if (Debug::log_stderr < 0) {
dup2(nullfd, 1);
dup2(nullfd, 2);
}
case CONF_LOG_FAC:
Answer = snmp_var_new(Var->name, Var->name_length);
- if (!(cp = Config.debugOptions))
+ if (!(cp = Debug::debugOptions))
cp = "None";
Answer->type = ASN_OCTET_STR;
char *as_whois_server;
struct {
- char *log;
char *store;
char *swap;
#if USE_USERAGENT_LOG
} Accel;
char *appendDomain;
size_t appendDomainLen;
- char *debugOptions;
char *pidFilename;
char *netdbFilename;
char *mimeTablePathname;
int httpd_suppress_version_string;
int global_internal_static;
int dns_require_A;
- int debug_override_X;
#if FOLLOW_X_FORWARDED_FOR
int acl_uses_indirect_client;
state = 1;
} else {
#ifndef MEM_GEN_TRACE
- Debug::parseOptions(Config.debugOptions);
+ Debug::parseOptions(Debug::debugOptions);
#else
log_trace_init("/tmp/squid.alloc");
fprintf(debug_log, "FATAL: %s\n", message);
- if (opt_debug_stderr > 0 && debug_log != stderr)
+ if (Debug::log_stderr > 0 && debug_log != stderr)
fprintf(stderr, "FATAL: %s\n", message);
fprintf(debug_log, "Squid Cache (Version %s): Terminated abnormally.\n",
/* MD5 cache keys */
typedef unsigned char cache_key;
-/* context-based debugging, the actual type is subject to change */
-typedef int Ctx;
-
/* in case we want to change it later */
typedef ssize_t mb_size_t;