6.6. How to print something to debug log file

With Caudium you can output something to the web page or to the debug log file located in ../logs/debug/default.*. This way the end-user will not see any line you can output in your debug log file. Sending output to the debug log file is simple, just write to stdout:

write("my message to log file\n");
      
It is also usually useful to use sprintf to format what you want to output:

int i = 2; write(sprintf("i=%d\n", i));
      
This line will output i=2, but it is better when you output array or mapping, as Pike is able to print them in a human-comprehensible format:

array a = ({ "test", "test2", 2 }); write(sprintf("a=%O\n", a));
      
Which will output:

a = ({ /* 2 elements */
    "test",
    "test2"
})
      

Note

the %O format is very useful since it can output any type from int to mapping. The only type you can't format is object.

mirror server hosted at Truenetwork, Russian Federation.