Print the current stack trace in ClojureScript? - stack-trace

I'm debugging a ClojureScript program and I want to know where this function is called from, but I don't want to interrupt its execution. I already have source maps working. How do I print the current stack trace to console?

Use the JavaScript Console API.
(.trace js/console)
In most browsers, it gives nice traces with source file links.
clojure.stacktrace/print-stack-trace is undefined in CLJS.

Related

Using codemirror to execute code on server

Novice to Codemirror.
I have codemirror running on my server I have it set to Python mode. Can someone please suggest how I go about executing the code and showing the result on the page where I have written the python code
Thanks
Without knowing much about your setup, here's a general idea:
Use the getValue() method to get the code from your CodeMirror instance.
Assuming the code is a run-able Python script, you can either
(1) send the code to your back end with AJAX or a POST request and run it there. Or (2) you could run the Python script in the browser with a library like one discussed here.
If you ran it on the back end, you can send the result of running the code back as text or JSON with your preferred protocol. If you ran it on the browser, you should probably follow the guidelines for the specific library you used.

Imprecise descriptions of bugs/exceptions when debugging EJS templates

EJS documentation at ejs.co says "It's easy to debug EJS errors: your errors are plain JavaScript exceptions, with template line-numbers included.".
However, when debugging the code with an bug in the template, I only get references to the functions inside my cza.js module that calls the ejs.renderFile and references to the "internal" errors within the EJS (ejs.js) itself. Reference to the bug within the .ejs template (ideally the line-number) is missing, in fact the template goes unmentioned.
So, the screenshot is of an the error within ejs.js, where EJS itself got stuck processing the bugged template, NOT the template itself, and so worthless:
So, how do I get the debugger to point out the bug in my template?
So, I have just found out that EJS does print out the code to terminal, unless a debugger does not step in to handle the exception before EJS can point out the bug.
In my scenario, I debug the app using node --inspect app.js, with debug auto-attach in VS Code enabled. The debugger then describes the exception as shown in the question screenshot.
How I found out the debugger was blocking EJS's output to terminal? I had a browser already requesting the app, when I launched it and the exception occured within the second before the debugger was attached.

how to get asl_log to appear in the iOS system console output?

I'm investigating whether I can get better performance from asl_log than NSLog on iPhone/iOS (probably...) but I'm stuck at a point where it doesn't seem that asl's log output will show up in the System Console (as viewable by a number of apps like System Console, iConsole, etc). I know that I'm setting it up right since I open with ASL_OPT_STDERR, and I see the log entries in XCode when the device is tethered.
I've explored lots of interesting stuff online (e.g. http://boredzo.org/blog/archives/2008-01-20/asl-logging, https://github.com/robbiehanson/CocoaLumberjack) and the best hope seemed to be asl_open() with Facility of "com.apple.console" but alas, the output still doesn't show up in Console. Is NSLog the only option?
Add STDERR to ASL and then it shows up in the console
asl_add_log_file(NULL, STDERR_FILENO);
You need to set read privileges on the message, using either ReadUID or ReadGID. Setting either to -1 will allow any user/group to view the message according to the header file documentation.
aslmsg msg = asl_new(ASL_TYPE_MSG);
asl_set(msg, ASL_KEY_READ_UID, "-1");
asl_log(NULL, msg, ASL_LEVEL_NOTICE, "Hello, world!");
asl_free(msg);

Handling errors/exceptions & logging them in iPhone applications

I wanted to know do we need to log the exceptions/errors in a common file in file system when an iPhone application runs for debugging purpose later point in time? Or this is handled by IOS automatically through device logs?
I now using NSLog statements we can print on consol but is there something similar to log4j in Java where you put all debugging statements including errors/exceptions in a single file which you can analyze later point in time.
What is the best way to handle such scenarios.
Some excellent info is found in this previous post on SO:
Logging to a file on the iPhone
Another good tip for logging in general is using the DLog macro:
http://iphoneincubator.com/blog/debugging/the-evolution-of-a-replacement-for-nslog

Can an Adobe AIR Application run via the command line output to console?

I have an AIR application that takes command-line arguments via onInvoke. All is good, but I cannot figure out how to print some status messages back to the user (to stdout / console, so to speak). Is it possible?
Even a default log file for traces would be fine, but I can't find any info about it anywhere. Do I need to create my own log file? Now that'd be silly.
Take a look at CommandProxy. It is a low level wrapper around your AIR application that lets you send command from AS3 back to the proxy for communicating with the underlying OS. You should be able to add a means of writing to the command line via such a method.
I don't think that is possible, but I'm not completely sure though.
There is a flashlog.txt file which you can configure so all trace() statements are logged to it. Check this post http://www.digitalflipbook.com/archives/2005/07/trace_from_the.php for more info on how to set it up. This is for logging from the browser, but I'm pretty sure it should also work from an air app.
Additionally, you could use SOS MAX from Powerflasher to log to an external console through an XML socket.
By default, trace() will output to stdout.
Your AIR application is one, big trace window if you want it to be.