abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Logs.java
blob: 027fa55c477bcaacb1aa813225d9d569416c42fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package juloo.keyboard2;

import android.text.InputType;
import android.util.Log;
import android.util.LogPrinter;
import android.view.inputmethod.EditorInfo;
import org.json.JSONException;

public final class Logs
{
  static final String TAG = "juloo.keyboard2";

  static LogPrinter _debug_logs = null;

  public static void set_debug_logs(boolean d)
  {
    _debug_logs = d ? new LogPrinter(Log.DEBUG, TAG) : null;
  }

  public static void debug_startup_input_view(EditorInfo info, Config conf)
  {
    if (_debug_logs == null)
      return;
    info.dump(_debug_logs, "");
    if (info.extras != null)
      _debug_logs.println("extras: "+info.extras.toString());
    _debug_logs.println("class: "+(info.inputType & InputType.TYPE_MASK_CLASS));
    _debug_logs.println("flags: "+(info.inputType & InputType.TYPE_MASK_FLAGS));
    _debug_logs.println("variation: "+(info.inputType & InputType.TYPE_MASK_VARIATION));
  }

  public static void debug_config_migration(int from_version, int to_version)
  {
    debug("Migrating config version from " + from_version + " to " + to_version);
  }

  public static void debug(String s)
  {
    if (_debug_logs != null)
      _debug_logs.println(s);
  }

  public static void exn(String msg, Exception e)
  {
    Log.e(TAG, msg, e);
  }

  public static void trace()
  {
    if (_debug_logs != null)
      _debug_logs.println(Log.getStackTraceString(new Exception()));
  }
}