Hi,
I'm wondering if there are any logging frameworks available for XQuery? I've searched around and can't find much other than the built in fn:trace and fn:error functions. I'm looking for something that can log to different levels (e.g. INFO, DEBUG, ERROR) but also be disabled for no output. I was thinking it would be something built around fn:trace and fn:error.
I've considered writing a RESTful logging service – have others used this approach?
Thanks, Dustin
On 06/03/2013 09:45 PM, Dustin Schultz wrote:
Hi,
I'm wondering if there are any logging frameworks available for XQuery? I've searched around and can't find much other than the built in fn:trace and fn:error functions. I'm looking for something that can log to different levels (e.g. INFO, DEBUG, ERROR) but also be disabled for no output. I was thinking it would be something built around fn:trace and fn:error.
I've considered writing a RESTful logging service -- have others used this approach?
Thanks, Dustin
Hi Dustin, we faced the same issues and implemented our own. Check if this could help you, you can add it as a module and modify the logging messages according to your need. ---------------------------------------------------------------------------------------- module namespace xqlogger = 'urn:sample:xqlogger';
declare variable $xqlogger:LOGDIR as xs:string := "./"; declare variable $xqlogger:LOGFILENAME as xs:string := "a.log"; declare variable $xqlogger:LOGFILESIZE as xs:integer := 100000; (: in bytes :)
declare variable $xqlogger:LOGSTATUSMAP := map { 0 := "INFO", 1 := "WARNING", 2 := "ERROR" };
declare function xqlogger:logger($logcode,$logmsg) { let $logstatus := map:get($xqlogger:LOGSTATUSMAP, $logcode) let $logfilepath := concat($xqlogger:LOGDIR,$xqlogger:LOGFILENAME) let $logtime := current-dateTime() return ( file:append-text-lines($logfilepath, concat($logtime,' ',$logstatus,': ',$logmsg)), if(file:size($logfilepath) >= $xqlogger:LOGFILESIZE) then file:move($logfilepath, concat($xqlogger:LOGDIR,file:last-modified($logfilepath),'-',$xqlogger:LOGFILENAME)) else () ) }; ----------------------------------------------------------------------------------------------- Thanks
*Seenivasan*
Thanks Seenivasan, this is extremely helpful – just what I was looking for.
Dustin
From: Seenivasan Gunabalan <seenivasan.gunabalan@dedalus.eumailto:seenivasan.gunabalan@dedalus.eu> Date: Tuesday, June 4, 2013 7:36 AM To: "basex-talk@mailman.uni-konstanz.demailto:basex-talk@mailman.uni-konstanz.de" <basex-talk@mailman.uni-konstanz.demailto:basex-talk@mailman.uni-konstanz.de> Subject: Re: [basex-talk] Logging Modules/Framework for XQuery
module namespace xqlogger = 'urn:sample:xqlogger';
declare variable $xqlogger:LOGDIR as xs:string := "./"; declare variable $xqlogger:LOGFILENAME as xs:string := "a.log"; declare variable $xqlogger:LOGFILESIZE as xs:integer := 100000; (: in bytes :)
declare variable $xqlogger:LOGSTATUSMAP := map { 0 := "INFO", 1 := "WARNING", 2 := "ERROR" };
declare function xqlogger:logger($logcode,$logmsg) { let $logstatus := map:get($xqlogger:LOGSTATUSMAP, $logcode) let $logfilepath := concat($xqlogger:LOGDIR,$xqlogger:LOGFILENAME) let $logtime := current-dateTime() return ( file:append-text-lines($logfilepath, concat($logtime,' ',$logstatus,': ',$logmsg)), if(file:size($logfilepath) >= $xqlogger:LOGFILESIZE) then file:move($logfilepath, concat($xqlogger:LOGDIR,file:last-modified($logfilepath),'-',$xqlogger:LOGFILENAME)) else () ) };
basex-talk@mailman.uni-konstanz.de