summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2012-09-12 17:13:02 +0000
committerJonathan Rose <jrose@digium.com>2012-09-12 17:13:02 +0000
commit1a79c9c18234fd8329e2315dec862cf7c32db8b3 (patch)
tree85e48acecacd64a7ca542938103776f4e5cb3d39 /main/logger.c
parentb0a4f08928eb2d3677eee122f2ffce04eb7dd076 (diff)
logger: Add rotatestrategy option of 'none' which does not perform rotations
With this option in use, it may be necessary to regulate your log files externally. (closes issue ASTERISK-20189) Reported by: Jaco Kroon Patches: asterisk-logger-norotate-trunk.patch uploaded by Jaco Kroon (license 5671) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372976 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/main/logger.c b/main/logger.c
index e85676857..5ff308009 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -92,6 +92,7 @@ struct ast_callid {
AST_THREADSTORAGE_CUSTOM(unique_callid, NULL, unique_callid_cleanup);
static enum rotatestrategy {
+ NONE = 0, /* Do not rotate log files at all, instead rely on external mechanisms */
SEQUENTIAL = 1 << 0, /* Original method - create a new file, in order */
ROTATE = 1 << 1, /* Rotate all files, such that the oldest file has the highest suffix */
TIMESTAMP = 1 << 2, /* Append the epoch timestamp onto the end of the archived file */
@@ -427,6 +428,8 @@ static void init_logger_chain(int locked, const char *altconf)
rotatestrategy = ROTATE;
} else if (strcasecmp(s, "sequential") == 0) {
rotatestrategy = SEQUENTIAL;
+ } else if (strcasecmp(s, "none") == 0) {
+ rotatestrategy = NONE;
} else {
fprintf(stderr, "Unknown rotatestrategy: %s\n", s);
}
@@ -610,6 +613,9 @@ static int rotate_file(const char *filename)
char *suffixes[4] = { "", ".gz", ".bz2", ".Z" };
switch (rotatestrategy) {
+ case NONE:
+ /* No rotation */
+ break;
case SEQUENTIAL:
for (x = 0; ; x++) {
snprintf(new, sizeof(new), "%s.%d", filename, x);
@@ -810,7 +816,7 @@ static int reload_logger(int rotate, const char *altconf)
}
if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
int rotate_this = 0;
- if (ftello(f->fileptr) > 0x40000000) { /* Arbitrarily, 1 GB */
+ if (rotatestrategy != NONE && ftello(f->fileptr) > 0x40000000) { /* Arbitrarily, 1 GB */
/* Be more proactive about rotating massive log files */
rotate_this = 1;
}