Changeset 2880 for WAeUP_SysConf/logging/trunk
- Timestamp:
- 8 Dec 2007, 00:48:01 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SysConf/logging/trunk/usr/local/lib/zevents.py
r2879 r2880 23 23 ## 24 24 25 ## 26 ## Usage: python zevents.py [-INSERT] 27 ## 28 ## Reads Zope event logs from stdin and turn it into PostGres compatible 29 ## output on stdout. 30 ## 31 ## If no options are given, output is formatted as a COPY command, which is 32 ## *much* (50 times or more) faster in PostGres. 33 ## 34 ## If -INSERT is given, output is formatted as a list of INSERT statements, 35 ## which will need much more time and resources. 36 ## 37 25 38 import sys 26 39 import re … … 32 45 ## 33 46 mode = "COPY" 47 48 if '-INSERT' in sys.argv: 49 mode = "INSERT" 34 50 35 51 faillog = "/var/log/updatedblog/zevents-failed.log" … … 66 82 data = data.replace("\t", " ") 67 83 return data 84 85 def q(text): 86 return text.replace("'","\\\'") 68 87 69 88 def print_dataset(data, lnum, mode): … … 107 126 ) 108 127 else: 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']128 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','%s');" % ( 129 val['id'], q(val['date']), q(val['time']), q(val['msg_src']), 130 q(val['msg_text']), q(val['err_type']), q(val['err_msg']), 131 q(val['traceback']), q(val['loglevel']) 113 132 ) 114 133 return
Note: See TracChangeset for help on using the changeset viewer.