Android Open Source - mac-hopper Logger






From Project

Back to project page mac-hopper.

License

The source code is released under:

MIT License

If you think the Android project mac-hopper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package uk.co.danhawkes.machopper;
/* ww  w .jav a2s. co  m*/
import java.text.DateFormat;
import java.util.Date;

import android.content.Context;
import de.greenrobot.event.EventBus;

public class Logger {

  private final DateFormat dateFormat;
  private final StringBuilder stringBuilder = new StringBuilder();
  private final EventBus eventBus;

  public static class LogAppendedEvent {

    private final String message;

    public LogAppendedEvent(String message) {
      this.message = message;
    }

    public String getMessage() {
      return message;
    }
  }

  public Logger(Context context, EventBus bus) {
    this.eventBus = bus;
    this.dateFormat = android.text.format.DateFormat.getTimeFormat(context);
  }

  public void log(String message) {
    stringBuilder.append(dateFormat.format(new Date()));
    stringBuilder.append(" | ");
    stringBuilder.append(message);
    stringBuilder.append("\n");
    eventBus.post(new LogAppendedEvent(message));
  }

  public String getLog() {
    return stringBuilder.toString();
  }
}




Java Source Code List

uk.co.danhawkes.machopper.AlarmUtils.java
uk.co.danhawkes.machopper.AppSingleton.java
uk.co.danhawkes.machopper.Application.java
uk.co.danhawkes.machopper.Logger.java
uk.co.danhawkes.machopper.Store.java
uk.co.danhawkes.machopper.mac.MacChangeBroadcastReceiver.java
uk.co.danhawkes.machopper.mac.MacUtils.java
uk.co.danhawkes.machopper.mac.Mac.java
uk.co.danhawkes.machopper.ui.CountdownFragment.java
uk.co.danhawkes.machopper.ui.HelpDialogFragment.java
uk.co.danhawkes.machopper.ui.LogFragment.java
uk.co.danhawkes.machopper.ui.MainActivity.java
uk.co.danhawkes.machopper.ui.preferences.ContactPreference.java
uk.co.danhawkes.machopper.ui.preferences.DonatePreference.java
uk.co.danhawkes.machopper.ui.preferences.PreferenceActivity.java
uk.co.danhawkes.machopper.ui.preferences.PreferenceFragment.java
uk.co.danhawkes.machopper.ui.preferences.TimePreference.java
uk.co.danhawkes.machopper.ui.preferences.UiUtils.java