Ignore:
Timestamp:
8 Dec 2007, 00:05:14 (17 years ago)
Author:
uli
Message:

Overlong fields are corrected now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SysConf/logging/trunk/usr/local/lib/zevents.py

    r2838 r2879  
    9090        }
    9191
     92    # If msg_text is too long, append it to traceback...
     93    if len(val['msg_text']) > 1024:
     94        val['traceback'] = val['msg_text'] + " " + val['traceback']
     95        val['msg_text'] = val['msg_text'][:1024]
     96
     97    # Shorten overlong fields...
     98    for name,maxlen in [('loglevel',32), ('msg_src',1024), ('msg_text', 1024),
     99                 ('err_type', 32), ('err_msg', 1024)]:
     100        val[name]=val[name][:maxlen]
     101
    92102    if mode == "COPY":
    93103        print "%07d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (
    94             val['id'], val['date'], val['time'], val['loglevel'],
    95             val['msg_src'], val['msg_text'], val['err_type'], val['err_msg'],
    96             val['traceback']
     104            val['id'], val['date'], val['time'], val['msg_src'],
     105            val['msg_text'], val['err_type'], val['err_msg'], val['traceback'],
     106            val['loglevel']
    97107        )
    98108    else:
    99         print "INSERT INTO \"ZEVENTS\" (\"ID\",\"DATE\",\"TIME\",\"LOGLEVEL\",\"MSG_SRC\",\"MSG_TEXT\",\"ERR_TYPE\",\"ERR_MSG\",\"TRACEBACK\") VALUES ('%07d','%s','%s','%s','%s','%s','%s','%s','%s');" % (
    100             val['id'], val['date'], val['time'], val['loglevel'],
    101             val['msg_src'], val['msg_text'], val['err_type'], val['err_msg'],
    102             val['traceback']
     109        print "INSERT INTO \"ZEVENTS\" (\"ID\",\"DATESTR\",\"TIMESTR\",\"MSG_SRC\",\"MSG\",\"ERR_TYPE\",\"ERR_MSG\",\"TRACEBACK\",\"LOGLEVEL\") VALUES ('%07d','%s','%s','%s','%s','%s','%s','%s');" % (
     110            val['id'], val['date'], val['time'], val['msg_src'],
     111            val['msg_text'], val['err_type'], val['err_msg'], val['traceback'],
     112            val['loglevel']
    103113        )
    104114    return
Note: See TracChangeset for help on using the changeset viewer.