Lines Matching refs:config

102 static rotate_config_t config;
164 static adjusted_time_t get_now(rotate_config_t *config, apr_int32_t *offset)
169 if (config->use_localtime) {
179 utc_offset = config->utc_offset;
191 static void close_logfile(rotate_config_t *config, struct logfile *logfile)
193 if (config->verbose) {
203 static void dumpConfig (rotate_config_t *config)
205 fprintf(stderr, "Rotation time interval: %12d\n", config->tRotation);
206 fprintf(stderr, "Rotation size interval: %12d\n", config->sRotation);
207 fprintf(stderr, "Rotation time UTC offset: %12d\n", config->utc_offset);
208 fprintf(stderr, "Rotation based on localtime: %12s\n", config->use_localtime ? "yes" : "no");
209 fprintf(stderr, "Rotation file date pattern: %12s\n", config->use_strftime ? "yes" : "no");
210 fprintf(stderr, "Rotation file forced open: %12s\n", config->force_open ? "yes" : "no");
211 fprintf(stderr, "Create parent directories: %12s\n", config->create_path ? "yes" : "no");
212 fprintf(stderr, "Rotation verbose: %12s\n", config->verbose ? "yes" : "no");
214 fprintf(stderr, "Rotation create empty logs: %12s\n", config->create_empty ? "yes" : "no");
216 fprintf(stderr, "Rotation file name: %21s\n", config->szLogRoot);
217 fprintf(stderr, "Post-rotation prog: %21s\n", config->postrotate_prog ? config->postrotate_prog : "not used");
232 static void checkRotate(rotate_config_t *config, rotate_status_t *status)
237 else if (config->sRotation) {
245 if (current_size > config->sRotation) {
248 else if (config->tRotation) {
249 if (get_now(config, NULL) >= status->tLogEnd) {
254 else if (config->tRotation) {
255 if (get_now(config, NULL) >= status->tLogEnd) {
264 if (status->rotateReason != ROTATE_NONE && config->verbose) {
273 rotate_config_t *config, rotate_status_t *status)
281 if (config->linkfile) {
282 apr_file_remove(config->linkfile, newlog->pool);
283 if (config->verbose) {
284 fprintf(stderr, "Linking %s to %s\n", newlog->name, config->linkfile);
286 rv = apr_file_link(newlog->name, config->linkfile);
289 newlog->name, config->linkfile, &rv);
295 if (!config->postrotate_prog) {
306 "for '%s': %pm\n", config->postrotate_prog, &rv);
317 "attributes for '%s': %pm\n", config->postrotate_prog,
323 argv[0] = config->postrotate_prog;
333 if (config->verbose)
339 "'%s': %pm\n", config->postrotate_prog, &rv);
374 static void doRotate(rotate_config_t *config, rotate_status_t *status)
383 now = get_now(config, &offset);
387 if (config->tRotation) {
390 tLogStart = (now / config->tRotation) * config->tRotation;
391 tLogEnd = tLogStart + config->tRotation;
406 if (config->use_strftime) {
414 if (config->use_localtime)
418 apr_strftime(newlog.name, &rs, sizeof(newlog.name), config->szLogRoot, &e);
421 if (config->truncate) {
422 apr_snprintf(newlog.name, sizeof(newlog.name), "%s", config->szLogRoot);
424 else if (config->num_files > 0) {
425 if (status->fileNum == -1 || status->fileNum == (config->num_files - 1)) {
427 apr_snprintf(newlog.name, sizeof(newlog.name), "%s", config->szLogRoot);
431 apr_snprintf(newlog.name, sizeof(newlog.name), "%s.%d", config->szLogRoot, thisLogNum);
435 apr_snprintf(newlog.name, sizeof(newlog.name), "%s.%010ld", config->szLogRoot,
440 if (config->create_path) {
444 if (config->verbose) {
457 if (config->verbose) {
461 | (config->truncate || (config->num_files > 0 && status->current.fd) ? APR_TRUNCATE : 0),
465 post_rotate(newlog.pool, &newlog, config, status);
470 close_logfile(config, &status->current);
512 static const char *get_time_or_size(rotate_config_t *config,
530 if (config->sRotation > 0) {
534 config->sRotation = atoi(arg) * mult;
536 if (config->sRotation == 0) {
540 else if ((config->sRotation > 0 || config->tRotation > 0) && last) {
542 if (config->use_localtime) {
545 config->utc_offset = atoi(arg) * 60;
548 if (config->tRotation > 0) {
551 config->tRotation = atoi(arg);
552 if (config->tRotation <= 0) {
579 memset(&config, 0, sizeof config);
592 config.use_localtime = 1;
595 config.linkfile = opt_arg;
598 config.postrotate_prog = opt_arg;
605 config.force_open = 1;
608 config.create_path = 1;
611 config.truncate = 1;
614 config.verbose = 1;
617 config.echo = 1;
621 config.create_empty = 1;
625 config.num_files = atoi(opt_arg);
644 rv = apr_filepath_merge(&config.szLogRoot, "", argv[opt->ind++],
652 if ((err = get_time_or_size(&config, argv[opt->ind],
658 config.use_strftime = (strchr(config.szLogRoot, '%') != NULL);
660 if (config.use_strftime && config.num_files > 0) {
665 if (status.fileNum == -1 && config.num_files < 1) {
681 * Write out result of config parsing if verbose is set.
683 if (config.verbose) {
684 dumpConfig(&config);
688 if (config.create_empty && config.tRotation) {
700 if (config.force_open) {
701 doRotate(&config, &status);
707 if (config.create_empty && config.tRotation) {
708 polltimeout = status.tLogEnd ? status.tLogEnd - get_now(&config, NULL) : config.tRotation;
742 checkRotate(&config, &status);
744 doRotate(&config, &status);
770 if (config.echo) {