[rt-users] Day of the week

Matthew Seaman matthew.seaman at thebunker.net
Mon Jan 19 04:47:54 EST 2009


Tomáš Sára wrote:
> This shows no errors but instead of writing the day of the week into log 
> file it writes "0". I'm not sure what "localtime" is. Is it the variable 
> containing the local time? Something like:
>   my $localtime = my $now = RT::Date->new($RT::SystemUser);
>   $now->SetToNow;
> Or should I write there just "localhost"? None of this seem to work.

localtime() is a standard perl function that returns the time according to
the local timezone broken down into an array of fields: sec, min, hour,
day etc.  See: 'perldoc -f localtime' for the full story.  There's also
gmtime() which produces the UTC time in the same format.

Either of those two functions takes an optional argument which is a
timestamp expressed as 'seconds since the epoch' a.k.a. unix time --
without an argument they default to the current time.

If you just want to get a timestamp on your log records, then there's
potentially a much simpler method you could use.  Instead of logging
to a file, just use the Unix syslog instead: that will automatically
tag each line with a timestamp.  Something like:

Set($LogToSyslog    , 'debug');

(although this seems to be the default already).

	Cheers,

	Matthew

-- 
Dr Matthew Seaman                        The Bunker, Ash Radar Station
PGP: 0x60AE908C on servers               Marshborough Rd
Tel: +44 1304 814890                     Sandwich
Fax: +44 1304 814899                     Kent, CT13 0PL, UK

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090119/66b8addb/attachment.sig>


More information about the rt-users mailing list