Robust Logging Script

Jim Ault JimAultWins at yahoo.com
Thu May 1 18:49:19 EDT 2008


On 5/1/08 2:20 PM, "Sarah Reichelt" <sarah.reichelt at gmail.com> wrote:

> On Thu, May 1, 2008 at 9:52 PM, David Bovill <david at openpartnership.net>
> wrote:
>> Anyone have any experience logging events for several days or more (an event
>>  happens each second).... is it better to write them out as text files broken
>>  up into a few hundred lines - or  write it to a text file using the append
>>  syntax (not done this myself). It must be a common task that people have
>>  done before, but as it would take a day or so to test whether I'd chosen the
>>  most robust solution well hell thought I'd ask here :)
> 
> I tend to accumulate events in a field or custom property and write to
> file every so often but not after every event. Showing them in a field
> is very useful during testing, but slower than using CPs as the data
> gets larger, so once you are sure it is doing what you want, swap to
> using CPs, but with a method for displaying them if you need to check.
> 
> I would also write to a date-stamped file so that you start a new log
> file at midnight. This will keep the file sizes down if the app is
> running continuously.
> 
> Sarah
------------
A few suggestions from my limited experience:

1  devise a very terse encoding for older messages to keep the size much
smaller.  You can scan the file to convert back to verbose mode if needed

2  sequentially name (the seconds & "logEvents.txt") and start a new one if
the number of chars > yourMaxSizeDesired

3  keep the log in RAM, such as a custom property, and write once.

4  use the compress command in Rev to reduce file size

5  send yourself an email when the new file is created

6  send yourself an email and include the logFile.zip as an attachment

7  filter the log lines for "*error*" or such and create an 'errLog.txt'

8  email only the errors to you along with the time and date stamp

Hope this helps

Jim Ault
Las Vegas





More information about the use-livecode mailing list