console.trace("Here I am!") - prints stack trace in current position of code. Is it possible to start writing stack trace from the beginning of script (or certain position) till the end of script to external log file like (/tmp/myTraceFile_${process.pid})?
Related
Scenario:
create a .gd script (i.e. in GDScript)
Make it so that the script outputs an error to the Godot console.
More specifically: Make it so that the error is not a crash inside the low-level c++ code, but strictly something in the GDscript. For example, this kind of instruction: assert(false) .
This does not need to involve c++ in any way. Therefore in my opinion the location of this game error in the c++ codebase is irrelevant. All I want to know is in which GDScript this happened.
Yet, Godot says in which cpp file the error "occurred". Every time, it creates an extra line in the logs.
It slows down my work a lot: Every time, I need to read twice: First my brain makes me read that incorrect location (muscle memory: if the logs give you a stack trace, you look at the stack trace!). It takes one or two seconds for me to discard that line and read what's above: The "real" error with the "real" location of the problem (the GDscript).
Is there a way to not display the cpp file location whenever an error occurs in a GDScript?
It's not possible at the moment.
Is there a way to filter out the lines of code from error stack trace that I can't control or debug? I mean, my nodeJS project depends on many third party dependencies and I don't pretend to debug them. It just ads noise to the stack trace.
For example, here I just want to show lines 1 and 7, because the file prepareServer.js is the one I created, all the others are not mine.
Error
at buildAdministrationsObject (/home/joao/dev/geoptapi/prepareServer.js:350:11)
at /home/joao/dev/geoptapi/node_modules/async/dist/async.js:3638:28
at replenish (/home/joao/dev/geoptapi/node_modules/async/dist/async.js:443:21)
at iterateeCallback (/home/joao/dev/geoptapi/node_modules/async/dist/async.js:427:21)
at /home/joao/dev/geoptapi/node_modules/async/dist/async.js:324:20
at /home/joao/dev/geoptapi/node_modules/async/dist/async.js:3643:17
at /home/joao/dev/geoptapi/prepareServer.js:158:7
at wrapper (/home/joao/dev/geoptapi/node_modules/async/dist/async.js:271:20)
at iterateeCallback (/home/joao/dev/geoptapi/node_modules/async/dist/async.js:424:28)
at /home/joao/dev/geoptapi/node_modules/async/dist/async.js:324:20
Basically I just want to show in the stack files within my project and exclude files in node_modules/
Came up with this solution that strips out any line with /node_modules/ or \node_modules\
const stripedStack = (new Error().stack).replace(/^.*[\\/]node_modules[\\/].*$/gm, '').replace(/\n+/g, '\n')
console.error(stripedStack)
Now as I wanted :)
Error
at readShapefile (/home/joao/dev/geoptapi/prepareServer.js:106:16)
at /home/joao/dev/geoptapi/prepareServer.js:100:7
We have an application software running on Suse linux. What I want is that whenever there is a crash/fault in the software, a backtrace is generated with call stack information for the current thread(which faults).
We are currently using "backtrace()" and "backtrace_symbols_fd()" to try to get the trace but there is not much useful information. It does not give function names, line no. and filename.
Therefore, I starting looking for alternate options to use and found "libunwind". Wrote a small function to get backtrace and it does print function name with other register values(ip,sp). But still I can not get the filename and linenumbers. Is there a way I can programmatically do that ? What happens if I strip my binary file? Can I still get the filename/lineno info ?
I create new stack from mainstack and after I want to delete mainstack.
I can't it.
Here my code:
create stack "newstack"
go to stack "newstack"
delete stack "mainstack"
How do I do?
Thank you
Try this:
local tStackID
put the long ID of this stack into tStackID
create stack "newstack"
go to stack "newstack"
delete stack tStackID
That seems to work in a simple test.
The reason for the inability to delete the stack is probably the fact that a script of your main stack is still running. Try to send a message to the new stack. That way, no script in the old stack will be running when it is time to delete it.
on createNewStack
local myStackID
put the long ID of this stack into myStackID
create stack "newstack"
go to stack "newstack"
send "deleteOldStack myStackID" to stack "newstack" in 0 secs
end createNewStack
on deleteOldStack theStackID
delete stack theStackID
end deleteOldStack
Call createNewStack from a mouseUp handler for instance. Put the createNewStack in the same button, card or stack as the mouseUp handler (if you put createNewStack at stack level, you can put the mouseUp handler at button level, but they have to be in the same stack).
Put the deleteOldStack handler into the new stack at stack level. It will run when the script in the old stack finishes running.
Perhaps you are confusing the removal of a stack from memory, and the deletion of a file from the machine.
The first is indeed invoked as you wrote, using the "delete stack" command.
The second would require the use of the "delete file" command, appending the appropriate pathname.
If the code that removes the stack is inside an object or sub-stack, I think it must give an error. So you can try something like creating a stack and putting a code to that stack that is the one that removes the mainstack. Example:
on mouseUp
local tStack
put the long id of this stack into tStack
create stack "NewStak"
set the script of stack "NewStak" to "on deleteMainStack; delete" & tStack & "; end deleteMainStack"
send "deleteMainStack" to stack "NewStak" in 0.1 sec
end mouseUp
Please note that when creating a substack this is part of your mainstack. So if you delete the mainstack it deletes all its substack. The above code creates another mainstack and deletes the one I call it. One way to delete the minstack of a substack is to tell it to merge into its own mainstack and then to delete the previous one. Remaining the same only in memory and not in the disc, since the filename property is substack it as that of its mainstack.
I am using log4net to log errors in my C# application. I am logging the error to the csv file. I am also logging stack trace error to this log. But the issue is that the stack trace error is very long and is like 7 to 8 lines of error. So in the CSV file the output is coming out to be messy.
Does anyone have a suggestion as to how can i log stack trace error better to either csv or excel so that the whole stacke trace error message comes in one cel rather than being split into different lines?
Try using double quotes for the stack trace and any other similar strings.