Re: Log rotation

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Log rotation
Date: 2004-03-13 19:12:58
Message-ID: 40535D3A.8040407@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:

>Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>
>>Did anything ever come from this thread?
>>http://archives.postgresql.org/pgsql-hackers/2003-05/msg00603.php
>>(Heading: "Plan B for log rotation support: borrow Apache code")
>>
>>
>
>Only an entry on my depressingly long personal to-do list :-(
>
>I did take a look at the Apache rotator program, and found that it was
>probably more trouble to adopt than it's worth. It seemed to depend on
>a lot of configuration and library-routine infrastructure that we don't
>share. (No big surprise; I suppose someone trying to pull out a random
>bit of our backend code would be at least as unhappy.) I suspect it
>would be less trouble, as well as legalistically cleaner, to write our
>own from scratch.
>
>Andrew Sullivan offered Afilias' rotator script awhile back also.
>I think that works fine if you like a Perl script.
>
>
>

FWIW, in less than 30 minutes I took the log rotator from apache 1.3.29
(i.e. the latest non-APR version) and imported it into a fresh postgreql
tree. With very little massaging it built happily (see below).

If it will advance matters, I can submit this as a patch filling the
currently empty contrib/apache_logging directory. You could be right
about the legal stuff - worth talking to the apache folks?

cheers

andrew

[andrew(at)alphonso apache_logging]$ make
gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
-Wmissing-declarations rotatelogs.o -L../../src/port
-Wl,-rpath,/home/andrew/tpg/inst//lib -o rotatelogs
[andrew(at)alphonso apache_logging]$ rm rotatelogs
[andrew(at)alphonso apache_logging]$ rm rotatelogs.o
[andrew(at)alphonso apache_logging]$ make
gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
-Wmissing-declarations -I. -I../../src/include -D_GNU_SOURCE -c -o
rotatelogs.o rotatelogs.c -MMD
gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
-Wmissing-declarations rotatelogs.o -L../../src/port
-Wl,-rpath,/home/andrew/tpg/inst//lib -o rotatelogs
[andrew(at)alphonso apache_logging]$ ldd rotatelogs
libc.so.6 => /lib/tls/libc.so.6 (0x0065e000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0056a000)
[andrew(at)alphonso apache_logging]$ diff -cw
~/apache_1.3.29/src/support/rotatelogs.c rotatelogs.c
*** /home/andrew/apache_1.3.29/src/support/rotatelogs.c Mon Jul 14
14:31:26 2003
--- rotatelogs.c Sat Mar 13 13:47:41 2004
***************
*** 7,16 ****
*/


! #include "ap_config.h"
#include <time.h>
#include <errno.h>
#include <fcntl.h>

#if defined(WIN32) || defined(OS2)
#include <io.h>
--- 7,18 ----
*/


! #include "postgres.h"
#include <time.h>
#include <errno.h>
#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/types.h>

#if defined(WIN32) || defined(OS2)
#include <io.h>
[andrew(at)alphonso apache_logging]$ cat Makefile
# $PostgreSQL$

subdir = contrib/apache_logging
top_builddir = ../..
include $(top_builddir)/src/Makefile.global

PROGRAM = rotatelogs
OBJS = rotatelogs.o

include $(top_srcdir)/contrib/contrib-global.mk

#LIBS:=$(filter-out -lpgport, $(LIBS))
LIBS:=
[andrew(at)alphonso apache_logging]$

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2004-03-13 21:33:28 Re: Log rotation
Previous Message Lamar Owen 2004-03-13 18:13:21 Re: Log rotation