|
|
@ -309,14 +309,16 @@ type
|
|
|
|
## Error type raised when no record matches a given ID
|
|
|
|
## Error type raised when no record matches a given ID
|
|
|
|
|
|
|
|
|
|
|
|
var logService {.threadvar.}: Option[LogService]
|
|
|
|
var logService {.threadvar.}: Option[LogService]
|
|
|
|
|
|
|
|
var logger {.threadvar.}: Option[Logger]
|
|
|
|
|
|
|
|
|
|
|
|
proc logQuery*(methodName: string, sqlStmt: string, args: openArray[(string, string)] = []) =
|
|
|
|
proc logQuery*(methodName: string, sqlStmt: string, args: openArray[(string, string)] = []) =
|
|
|
|
# namespaced_logging would do this check for us, but we don't want to even
|
|
|
|
# namespaced_logging would do this check for us, but we don't want to even
|
|
|
|
# build the log object if we're not actually logging
|
|
|
|
# build the log object if we're not actually logging
|
|
|
|
if logService.isNone: return
|
|
|
|
if logService.isNone: return
|
|
|
|
|
|
|
|
if logger.isNone: logger = logService.getLogger("fiber_orm/query")
|
|
|
|
var log = %*{ "method": methodName, "sql": sqlStmt }
|
|
|
|
var log = %*{ "method": methodName, "sql": sqlStmt }
|
|
|
|
for (k, v) in args: log[k] = %v
|
|
|
|
for (k, v) in args: log[k] = %v
|
|
|
|
logService.getLogger("fiber_orm/query").debug(log)
|
|
|
|
logger.debug(log)
|
|
|
|
|
|
|
|
|
|
|
|
proc enableDbLogging*(svc: LogService) =
|
|
|
|
proc enableDbLogging*(svc: LogService) =
|
|
|
|
logService = some(svc)
|
|
|
|
logService = some(svc)
|
|
|
|