Java Code Examples for com.codename1.io.Log#sendLog()

The following examples show how to use com.codename1.io.Log#sendLog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultCrashReporter.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Installs a crash reporter within the system
 * @param promptUser indicates whether the user should be prompted on crash reporting
 * @param frequency the frequency with which we send the log to the server in debug mode in minutes
 * frequency must be at least 1. Any lower level automatically disables this feature
 */
public static void init(boolean promptUser, int frequency) {
    if(Preferences.get("$CN1_crashBlocked", false) || Log.getReportingLevel() == Log.REPORTING_NONE) {
        return;
    }
    if(Preferences.get("$CN1_pendingCrash", false)) {
        // we must have crashed during a report, send it.
        Log.sendLog();
        Preferences.set("$CN1_pendingCrash", false);
    }
    if(Log.getReportingLevel() == Log.REPORTING_DEBUG && frequency > 0) {
        java.util.Timer t = new java.util.Timer();
        t.schedule(new TimerTask() {
            public void run() {
                if(!Display.getInstance().isEdt()) {
                    Display.getInstance().callSerially(this);
                    return;
                }
                Log.sendLog();
            }
        }, frequency * 60000, frequency * 60000);
    }
    DefaultCrashReporter d = new DefaultCrashReporter();
    d.promptUser = promptUser && Preferences.get("$CN1_prompt", true);
    Display.getInstance().setCrashReporter(d);
}
 
Example 2
Source File: DefaultCrashReporter.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void exception(Throwable t) {
    Preferences.set("$CN1_pendingCrash", true);
    if(promptUser) {
        Dialog error = new Dialog("Error");
        error.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        TextArea txt = new TextArea(errorText);
        txt.setEditable(false);
        txt.setUIID("DialogBody");
        error.addComponent(txt);
        CheckBox cb = new CheckBox(checkboxText);
        cb.setUIID("DialogBody");
        error.addComponent(cb);
        Container grid = new Container(new GridLayout(1, 2));
        error.addComponent(grid);
        Command ok = new Command(sendButtonText);
        Command dont = new Command(dontSendButtonText);
        Button send = new Button(ok);
        Button dontSend = new Button(dont);
        grid.addComponent(send);
        grid.addComponent(dontSend);
        Command result = error.showPacked(BorderLayout.CENTER, true);
        if(result == dont) {
            if(cb.isSelected()) {
                Preferences.set("$CN1_crashBlocked", true);
            }
            Preferences.set("$CN1_pendingCrash", false);
            return;
        } else {
            if(cb.isSelected()) {
                Preferences.set("$CN1_prompt", false);
            }
        }
    }
    Log.sendLog();
    Preferences.set("$CN1_pendingCrash", false);
}
 
Example 3
Source File: CN.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sends the log to your email account
 */
public static void sendLog() {
    Log.sendLog();
}
 
Example 4
Source File: CodenameOneThread.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static void handleException(Throwable err) {
    if(Log.isCrashBound()) {
        Log.e(err);
        Log.sendLog();
    }
}