[personal kdb+] Logging

307 views
Skip to first unread message

Victor Wong

unread,
Apr 19, 2010, 7:56:38 PM4/19/10
to Kdb+ Personal Developers
Hi,

I'm having some trouble getting logging to work following the
instructions here: https://code.kx.com/trac/wiki/Cookbook/Logging.
For some reason, messages sent to the 0 handle doesn't seem to get
written into the log, but messages sent from other processes do.
Here's my test setup:

test3.q:
\p 5012
ins:insert;
x:([]a:();b:());
0(`ins;`x;(1;2))

showlog.q:
.z.ps:{0N!x}

command line:
q test3 -l
q
q)h:hopen`::5012; h(`ins;x;(3;4)); h(`ins;x;(5;6));
q)\\
copy test3.log showlog.log
q showlog -l
(`ins;`x;3 4)
(`ins;`x;5 6)

I am wondering why the insert from inside test3.q isn't written to the
log. I wrote a C module which I am loading as a shared library to
read data into kdb. However, since I can't seem to write to the log
from inside a kdb process, I am now wondering whether I will need to
rewrite the library into a separate process.

Thanks,
Victor

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To post to this group, send email to personal...@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.

Xi Chen

unread,
Apr 19, 2010, 8:21:42 PM4/19/10
to personal...@googlegroups.com
Hi,

It is not the problem of the 0 handle, i think it is the way you start
up the logging process
q)h:hopen`::5012;
q)h
0
q)

q abc -l
q)\l test3.q
,0
q)\\

copy abc.log showlog.log
q showlog -l
(`ins;`x;1 2)


Regards,
Xi

Victor Wong

unread,
Apr 20, 2010, 7:05:30 PM4/20/10
to Kdb+ Personal Developers
Thanks, Xi. You example works for me. However, when I attempt to
apply it to my problem, I can't seem to get it to work. I call a q
function from my C shared library when data comes in (via a socket
registered with sd1()), and in that function, I make the call to the 0
handle. Attaching a 0N! to .z.ps confims that this call is being made
and is successful. For some reason though, this doesn't get written
to the log. I have tried this both by specifying the q script on the
command line and by loading it via \l.

Is there an explicit function to write to a log file, something of an
inverse to -11! ?

Thanks,
Victor

On Apr 19, 5:21 pm, Xi Chen <heydic...@gmail.com> wrote:
> Hi,
>
> It is not the problem of the 0 handle, i think it is the way you start
> up the logging process
> q)h:hopen`::5012;
> q)h
> 0
> q)
>
> q abc -l
> q)\l test3.q
> ,0
> q)\\
>
> copy abc.log showlog.log
> q showlog -l
> (`ins;`x;1 2)
>
> Regards,
> Xi
>
> > For more options, visit this group athttp://groups.google.com/group/personal-kdbplus?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
> To post to this group, send email to personal...@googlegroups.com.
> To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/personal-kdbplus?hl=en.

Charles Skelton

unread,
Apr 21, 2010, 10:37:15 AM4/21/10
to personal...@googlegroups.com
unfortunately the logging is restricted to sockets that kdb+ itself reads; not accessible from c.

however, you can always roll your own log file

`:log set ();
h:hopen `:log;
n:0;
do[10;h enlist (`fn;n+:1)];
hclose h;
fn:{0N!x};
-11!`:log

which you can figure out how to call from c
Reply all
Reply to author
Forward
0 new messages