96 Commits

Author SHA1 Message Date
d7ac6428db s/to to/to/
[skip ci]

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1907993 13f79535-47bb-0310-9956-ffa450edef68
2023-03-02 19:50:12 +00:00
d0eac89e98 add -T flag to truncate rotated logs only
for strftime formats that will loop back on themselves, like
day of month or weekday name.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906433 13f79535-47bb-0310-9956-ffa450edef68
2023-01-06 23:46:35 +00:00
43f0c91fd0 minor tweak to -n with size rotation
Without -t, One line can be added to base "logfile" even when
it's over the size limit already.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906428 13f79535-47bb-0310-9956-ffa450edef68
2023-01-06 20:45:16 +00:00
85760859ca Fix spelling errors found by codespell. [skip ci]
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1873985 13f79535-47bb-0310-9956-ffa450edef68
2020-02-13 18:15:57 +00:00
d7b14caa57 rotatelogs: fix -n help text
this closes #24

Submitted By: Isaac Boukris <iboukris gmail.com>



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1780308 13f79535-47bb-0310-9956-ffa450edef68
2017-01-26 02:02:59 +00:00
f222f9fdf0 Choose "-D" instead of "-d" for the rotatelogs
option that creates the path to the log file.

I want to use "-d" for another directory related
option next where (I think) the "directory" "d"
makes more sense.

"-d" has not yet been backported, so changing
to "-D" is not a real compatibility issue.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1666417 13f79535-47bb-0310-9956-ffa450edef68
2015-03-13 12:24:17 +00:00
d6cb8ec8e3 Small changes to rotatelogs:
- add "-n num" to help text
- clarify in help text, that "program is invoked"
  is the "-p" case
- prevent crash with "-v" (verbose) if no
  "-p prog" is used
- add one space for formatting


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1666415 13f79535-47bb-0310-9956-ffa450edef68
2015-03-13 12:15:40 +00:00
b7d63d4da7 * support/rotatelogs.c (main): Prevent creation of zombies from
post-rotate programs.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1587255 13f79535-47bb-0310-9956-ffa450edef68
2014-04-14 16:38:30 +00:00
30f8aa6460 more apr_file_write_full() simplification (like r1542413)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1542416 13f79535-47bb-0310-9956-ffa450edef68
2013-11-15 22:03:16 +00:00
00cf228909 * support/rotatelogs.c: Introduce an adjusted_time_t type to store the
weird "adjusted time since epoch" type returned by get_now().
  Switch from int to long to fix an unnecessary Y2K38 issue.  Adjust
  use throughout and clean up other type issues.  No functional change
  intended apart from fixing Y2K38.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1537718 13f79535-47bb-0310-9956-ffa450edef68
2013-10-31 21:58:31 +00:00
386cb9c13c rotatelogs: Remove last constant length error buffer.
* support/rotatelogs.c
  (ERRMSGSZ): Remove.
  (rotate_status): Remove errbuff member.
  (truncate_and_write_error): Accept the error message as an argument.
  (doRotate): Shift the pool destruction slightly later and use it to generate
    the error message to pass truncate_and_write_error().
  (main): In case of write errors create a pool to generate the error message,
    since the other pools available may never been freed.  Adjust to pass
    message directly to truncate_and_write_error().


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1534914 13f79535-47bb-0310-9956-ffa450edef68
2013-10-23 05:14:45 +00:00
1eb6352e2a rotatelogs: Remove another use of a consant length buffer for errors.
* support/rotatelogs.c
  (doRotate): Use apr_psprintf() and %pm.  Move the destruction of the pool
    after we're done with the error message so the error string stays allocated
    long enough.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1534896 13f79535-47bb-0310-9956-ffa450edef68
2013-10-23 03:12:46 +00:00
e2e2cd9b25 rotatelogs: Use apr_psprintf() with %pm instead of a constant length buffer for
errors.

* support/rotatelogs.c
  (post_rotate, doRotate): Switch to using apr_psprintf() with %pm.

Suggested by: rpluem


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1534895 13f79535-47bb-0310-9956-ffa450edef68
2013-10-23 03:01:05 +00:00
779bd67fa2 Add an option to autocreate directories to rotatelogs.
* support/rotatelogs.c
  (rotate_config): Remove const from szLogRoot since we'll be passing it to
    apr_filepath_merge.  Add create_path member.
  (usage, dumpConfig): Update to reflect new -d option.
  (doRotate): Add code that knows how to create the directories a log file
    is going to go into.
  (main): Add the -d option and canonicalize the incoming path with
    apr_filepath_merge() so that the code in doRotate can work properly.

* docs/man/rotatelogs.8,
  docs/manual/programs/rotatelogs.html.en: Update for -d option.

PR: 46669
Submitted by: Philippe Lantin <plantin cobaltgroup.com>
              (which was actually a patch written by myself when I worked there)
Tweaked by: breser (ported to trunk and changed option from -p to -d)



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1533810 13f79535-47bb-0310-9956-ffa450edef68
2013-10-19 19:10:33 +00:00
ce61f94003 * support/rotatelogs.c (get_now): Fix the NULL ptr dereferences
added in r1532281.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1532289 13f79535-47bb-0310-9956-ffa450edef68
2013-10-15 11:19:38 +00:00
fd4ae8e200 * support/rotatelogs.c (get_now): Return the offset applied to the
Unix time as a parameter.
  (doRotate): When exploding the time for strtfime formatting, iff in
  -l mode, subtract the offset and explode the real Unix time as a
  local time so %Z etc works correctly.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1532281 13f79535-47bb-0310-9956-ffa450edef68
2013-10-15 10:44:17 +00:00
65f9d99f5c don't truncate the very first file opened (unless the truncate flag is there too)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1490761 13f79535-47bb-0310-9956-ffa450edef68
2013-06-07 18:12:17 +00:00
dab3bc1339 rotatelogs: add -n number-of-files option to roate through a number
of fixed-name logfiles. 




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1490493 13f79535-47bb-0310-9956-ffa450edef68
2013-06-07 01:51:31 +00:00
a9f8426059 Use apr_snprintf(... "%pm"...) instead of explicit call to apr_strerror
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1463736 13f79535-47bb-0310-9956-ffa450edef68
2013-04-02 20:20:12 +00:00
c53f52c997 error[120] is already defined in this function. Just use it instead of shadowing.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1416121 13f79535-47bb-0310-9956-ffa450edef68
2012-12-02 07:19:22 +00:00
544bf732e4 * support/rotatelogs.c: Cleanups, no functional change. Drop revision
history, "svn log" works; use APR_PATH_MAX; constify more.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1409800 13f79535-47bb-0310-9956-ffa450edef68
2012-11-15 14:19:57 +00:00
ffef83181f * support/rotatelogs.c (post_rotate): Really omit the second arg when
invoking a post-rotate program, rather than passing an empty arg.
  (Fixes to code match desired&documented behaviour.)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1409726 13f79535-47bb-0310-9956-ffa450edef68
2012-11-15 10:40:37 +00:00
4f1e2bb5f8 * support/rotatelogs.c (truncate_and_write_error): Factor out from
doRotate, main; make error handling consistant and print the actual
  error to stderr.
  (doRotate, main): Use it.

PR: 45084


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1374247 13f79535-47bb-0310-9956-ffa450edef68
2012-08-17 13:41:15 +00:00
fe4f92509b Replace use of apr_file_write() with apr_file_write_full() to prevent
incomplete writes.

Add comments in some places where error handling/logging is missing.

PR: 53131.
Submitted by: Nicolas Viennot <apache viennot biz>, Stefan Fritsch


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1331110 13f79535-47bb-0310-9956-ffa450edef68
2012-04-26 21:44:51 +00:00
a45cbef86b * support/rotatelogs.c (usage, main): Add support for -c option.
Submitted by: Jan Kaluža <jkaluza redhat.com>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1189220 13f79535-47bb-0310-9956-ffa450edef68
2011-10-26 13:54:42 +00:00
427c85bd23 Cleanup effort in prep for GA push:
Trim trailing whitespace... no func change



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1174751 13f79535-47bb-0310-9956-ffa450edef68
2011-09-23 13:39:32 +00:00
01792b69b7 * support/rotatelogs.c (main): Exit with success on EOF.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1140226 13f79535-47bb-0310-9956-ffa450edef68
2011-06-27 16:16:56 +00:00
b3e11effb7 Simplify state handling in rotatelogs, fixing -L support in the case
where open() fails for a new log file.

* support/rotatelogs.c (struct logfile): New structure.
  (struct rotate_status): Store only current logfile state here, using
  struct logfile.
  (close_logfile): Rename from closeFile; assume a valid logfile
  structure is passed in; simplify to use stored filename.
  (checkRotate, main): Adjust for new structure.
  (post_rotate): Adjust, move linkfile handling here.
  (doRotate): Simplify.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1140138 13f79535-47bb-0310-9956-ffa450edef68
2011-06-27 12:29:34 +00:00
550078b731 Tweak rotatelogs -p such that the program is invoked the first time a
new log file is opened as well as for rotations:

* support/rotatelogs.c (usage): Update.
  (post_rotate): Omit third arg if no prev logfile known.
  (doRotate): Invoke even if no previous logfile was open.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1140099 13f79535-47bb-0310-9956-ffa450edef68
2011-06-27 10:57:10 +00:00
0f14fc02dc rotatelogs: Add support for running a custom program after a log
rotation.

* support/rotatelogs.c (post_rotate): New function.
  (usage, dumpConfig): Update.
  (doRotate): Save old filename before rotate; call post_rotate after
  successful rotation.
  (main): Add -p argument.

* docs/manual/programs/rotatelogs.xml: Document -p.

PR: 51285
Submitted by: <sveniu ifi.uio.no>, jorton


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1137590 13f79535-47bb-0310-9956-ffa450edef68
2011-06-20 10:28:05 +00:00
74030fa378 rotatelogs: Add -e option to write logs through to stdout for optional
further processing.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1051582 13f79535-47bb-0310-9956-ffa450edef68
2010-12-21 17:52:43 +00:00
6fc811e664 With rotatelogs -v, on platforms where APR_FINFO_NAME is not implemented,
the verbose printf for closing the file never occurred because apr_file_info_get()
always returned APR_INCOMPLETE.  Fix that so we still get a printf with the
information we get back.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1024359 13f79535-47bb-0310-9956-ffa450edef68
2010-10-19 18:57:31 +00:00
39a167fb32 Renamed optarg -> opt_arg to avoid name clashes with system-own optarg;
removed leftover from IDE build times.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1004962 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 10:05:22 +00:00
81bea55361 Use portable apr_snprintf in rotatelogs.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@917029 13f79535-47bb-0310-9956-ffa450edef68
2010-02-27 19:56:06 +00:00
7335fa4f9e Add -L option to create a hard link to the current log file.
PR: 48761
Submitted by: <lindon orthanc.ca>
With additional changes by: poirier


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@916377 13f79535-47bb-0310-9956-ffa450edef68
2010-02-25 18:00:42 +00:00
78469c61be support/rotatelogs: Support the simplest log rotation case, log
truncation. Useful when the log is being processed in real time
using a command like tail.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@910719 13f79535-47bb-0310-9956-ffa450edef68
2010-02-16 22:01:21 +00:00
60fbe11de1 Bring back OS/2 support.
Reverses r758929 with a little bit of conflict resolution.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@807930 13f79535-47bb-0310-9956-ffa450edef68
2009-08-26 08:56:13 +00:00
ee32468a33 remove OS/2 platform support
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@758929 13f79535-47bb-0310-9956-ffa450edef68
2009-03-26 23:47:52 +00:00
643d77264c Mostly revert r733493: signal based rotation
for rotatelogs.

Prefer adding reliable piped logs to the error
loggers in httpd, so that one could simply
kill rotatelogs and httpd automatically starts new
instances of all loggers.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@734973 13f79535-47bb-0310-9956-ffa450edef68
2009-01-16 11:08:15 +00:00
11587a6fbe Adopt latest changes in usage message.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733532 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 22:52:47 +00:00
618c7592fc Allow size units B, K, M, G and combination of
time and size based rotation for rotatelogs.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733531 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 22:45:53 +00:00
fd96906302 rotatelogs: Add flag for verbose (debug) output.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733520 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 21:26:13 +00:00
d26bbe90fe More rotatelogs changes:
- checkRotate() notes the reason for rotation
- rename a few variables
- rename some macros and introduce a few more


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733517 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 20:58:19 +00:00
1f3c946071 Minor rotatelogs changes:
- remove 'now' from status struct. We only need it locally.
- add 'static' to function declaration, although the code
  is still in a single file
- change signature of get_now()
- make argument count check easier to understand


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733513 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 20:27:53 +00:00
091fe50066 Use APR_WANT_STRFUNC and apr_want.h instead
of APR_HAVE_* and system header inclusion.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733495 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 17:48:12 +00:00
d73d0412d5 Allow to trigger rotatelogs log file rotation from
using HUP and INT signals to the rotatelogs process.

This is helpful, when log activity is low, but you want
rotatelogs to close the open log files.

SIGHUP triggers checking the rules given during startup,
SIGINT forces rotate independently form those rules.

When the signal triggers a rotation, the open file
is closed immediately. The new file is opened when
new log data arrives, or in case "-f" was given it
is opened immediately.

Based on my patch in BZ 44427.

Note on Windows: The new functionality is undefined when
SIGHUP or SIGINT are not available. Does the use case
make sense on Windows? If so, which signals should we use?


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733493 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 17:36:07 +00:00
88d19bfcc5 Addition to r733479 and r733479:
Mainly cleanup plus correct decision in checkRotate()
if status->nLogFD is NULL.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733484 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 16:03:57 +00:00
4807369a2c Addition to r744476:
- Fix compilation error
- set correct time when forcing log file open
  on startup


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733479 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 14:44:51 +00:00
29290c61eb Refactor rotatelogs to allow easier implementation
of signal triggered log rotation.

- move code into new functions checkRotate() and doRotate()
- bundle config data and runtime data in two structs to
  allow easier passing to functions
- Simplify bypass_io logic as a first use case for doRotate
  and rename flag to force_open to reflect the new logic



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733476 13f79535-47bb-0310-9956-ffa450edef68
2009-01-11 14:05:39 +00:00
92c2a85ef4 rotatelogs: Log the current file size and error code/description
when failing to write to the log file. 

Sometimes users have a hard time believing that their little log
file was really big enough to reach quota/filesystem/other limit
back at the time of the error.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@646845 13f79535-47bb-0310-9956-ffa450edef68
2008-04-10 15:33:05 +00:00