[personal kdb+] Logging

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


Submitted via Google Groups

Hi,It is not the problem of the 0 handle, i think it is the way you startup the logging processq)h:hopen::5012;q)h0q)q abc -lq)\l test3.q,0q)\\copy abc.log showlog.logq showlog -l(ins;x;1 2)Regards,XiOn 20 April 2010 00:56, Victor Wong <victor.wong> wrote:&gt; Hi,&gt;&gt; I'm having some trouble getting logging to work following the&gt; instructions here: https://code.kx.com/trac/wiki/Cookbook/Logging.&gt; For some reason, messages sent to the 0 handle doesn't seem to get&gt; written into the log, but messages sent from other processes do.&gt; Here's my test setup:&gt;&gt; test3.q:&gt; \p 5012&gt; ins:insert;&gt; x:([]a:();b:());&gt; 0(ins;x;(1;2))&gt;&gt; showlog.q:&gt; .z.ps:{0N!x}&gt;&gt; command line:&gt; q test3 -l&gt; q&gt; 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>> –>

Submitted via Google Groups</victor.wong>

Thanks, Xi. You example works for me. However, when I attempt toapply it to my problem, I can’t seem to get it to work. I call a qfunction from my C shared library when data comes in (via a socketregistered with sd1()), and in that function, I make the call to the 0handle. Attaching a 0N! to .z.ps confims that this call is being madeand is successful. For some reason though, this doesn’t get writtento the log. I have tried this both by specifying the q script on thecommand line and by loading it via \l.Is there an explicit function to write to a log file, something of aninverse to -11! ?Thanks,VictorOn Apr 19, 5:21?pm, Xi Chen <heydic…> 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;&gt; q)h&gt; 0&gt; q)&gt;&gt; q abc -l&gt; q)\l test3.q&gt; ,0&gt; q)\\&gt;&gt; copy abc.log showlog.log&gt; q showlog -l&gt; (ins;x;1 2)&gt;&gt; Regards,&gt; Xi&gt;&gt; On 20 April 2010 00:56, Victor Wong <victor.w...> wrote:&gt;&gt;&gt;&gt;&gt;&gt; &gt; Hi,&gt;&gt; &gt; I'm having some trouble getting logging to work following the&gt; &gt; instructions here:https://code.kx.com/trac/wiki/Cookbook/Logging.&gt; &gt; For some reason, messages sent to the 0 handle doesn't seem to get&gt; &gt; written into the log, but messages sent from other processes do.&gt; &gt; Here's my test setup:&gt;&gt; &gt; test3.q:&gt; &gt; \p 5012&gt; &gt; ins:insert;&gt; &gt; x:([]a:();b:());&gt; &gt; 0(ins;x;(1;2))&gt;&gt; &gt; showlog.q:&gt; &gt; .z.ps:{0N!x}&gt;&gt; &gt; command line:&gt; &gt; q test3 -l&gt; &gt; q&gt; &gt; 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>> > –> >

Submitted via Google Groups</victor.w…></heydic…>

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