1 # vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4
3 class tlc
::Sqlitelogger {
10 variable flush_secs
0.1
18 method safelog
{usec instancename ns class method argdesc lvl msg
}
24 body tlc
::Sqlitelogger::constructor {args
} { #<<<
25 package require sqlite3
29 foreach reqf
{dbfile name
} {
30 if {![info exists
$reqf]} {
31 error "Required argument missing: -$reqf"
37 sqlite3
[namespace current
]::$db $dbfile
43 tlc
::Baselog::output_function [code
$this safelog
]
47 body tlc
::Sqlitelogger::destructor {} { #<<<
49 if {[info exists db
]} {
59 tlc
::Baselog::output_function {}
63 body tlc
::Sqlitelogger::init_db {} { #<<<
64 set exists
[$db onecolumn
{
77 id integer primary key autoincrement
,
83 id integer primary key autoincrement
,
96 set now
[tlc
::Baselog::timestamp]
109 body tlc
::Sqlitelogger::safelog {usec instancename ns class method argdesc lvl msg
} { #<<<
132 if {$flush_id == ""} {
133 set flush_id
[after [expr {round
($flush_secs * 1000)}] \
139 body tlc
::Sqlitelogger::flush {} { #<<<
140 after cancel
$flush_id; set flush_id
""
142 if {[info exists db
]} {
143 $db eval {commit
; begin
}