I use this code to capture the contents of a log file. Its a bit obscure
because it threads
a needle through the standard codename1 class "Log" to create a temporary
log file.
class LogCapture extends Log
{ Log oldLog;
StringWriter myWriter;
LogCapture()
{ oldLog = Log.getInstance();
install(this);
}
protected Writer createWriter() throws IOException
{ return(myWriter = new StringWriter());
}
public String dispose()
{
install(oldLog);
return(myWriter.toString());
}
}
then, this code can capture a stack trace as a string
public static String getStackTrace(Throwable t)
{
LogCapture cap = new LogCapture();
Log.e(t);
return cap.dispose();
}
Once acquired as a string, you can display it, save it to a file,
email it to yourself, or post it to a server you control.
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/63c021ec-a482-4761-b8dc-e29d00592879%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.