btrace icon indicating copy to clipboard operation
btrace copied to clipboard

Option to send output to a file

Open zeocio opened this issue 11 years ago • 5 comments

Can we add a "-o logfile" option to the client?

zeocio avatar Nov 20 '15 03:11 zeocio

You can add the following parameters:

stdout=false,fileRollMilliseconds=7500 

which will output to a .btrace file (alongside the main .btrace.class file), rolled over every 7500 milliseconds.

I agree, though, that an option “outputDirectory” would be quite useful to separate the .class files from the logs.

/** Med Vennlig Hilsen | Very Best Regards

  •   Joachim Haagen Skeie
    
  • @Degree, Bachelor and Master of Information Technology, QUT, Brisbane, Australia
  • @Title, Senior Consultant and Owner, Haagen Software AS
  • @Website: http://haagen-software.no
  • @Twitter: joachimhs
  • @Phone: +47 4141 5805 */

On 20 Nov 2015, at 04:22, Zee Chen [email protected] wrote:

Can we add a "-o logfile" option to the client?

— Reply to this email directly or view it on GitHub.

joachimhs avatar Nov 20 '15 06:11 joachimhs

You mean when using BTrace client to attach dynamically?

jbachorik avatar Nov 21 '15 13:11 jbachorik

@jbachorik actually yes!

The use case I have in mind is this:

  • I am writing test code (or app logic) against a library or framework
  • I want to use btrace to build a trace of intra-library calls to help me understand/debug its internals
  • the attaching of btrace to the jvm process needs to be controlled by the test/app logic, a blocking call to attach upon entry to a block and detach upon exit from that block.
  • the output of the btrace client in question can be either a file or a PrintStream/Logger in the current jvm.

void TestCaller() { // blocking call to attach to self btrace_attach_self(output, library_btrace_script);

// call library/framework internal logic here ...

btrace_detach(); }

zeocio avatar Nov 23 '15 19:11 zeocio

Let me know if I should open a new issue for the above mentioned use case.

zeocio avatar Nov 23 '15 19:11 zeocio

@joachimhs For the agent you can use traceOutputFile parameter to specify where the output should go. Not exactly outputDir but it can get you pretty far.

I have a prototype ready (https://github.com/jbachorik/btrace/tree/remote-output-file) for supporting the -o option when attaching dynamically - I suppose it does make sense to turn off printing the output in the BTrace console when an output file is specified. Kepping it on would basically double the IO requirements for the BTrace output I don't think it is reasonable to pay that price.

jbachorik avatar Mar 03 '16 16:03 jbachorik