Android Open Source - AmbientAlarmClock Logger






From Project

Back to project page AmbientAlarmClock.

License

The source code is released under:

<p align="center"><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/4.0...

If you think the Android project AmbientAlarmClock 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 de.lukeslog.alarmclock.support;
/*from w  w  w.java  2  s .c o m*/
import android.os.Environment;
import android.util.Log;

import org.joda.time.DateTime;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import de.lukeslog.alarmclock.main.ClockWorkService;

/**
 * Created by lukas on 28.05.14.
 */
public class Logger
{
    public static void i(String TAG, String m)
    {
        if(ClockWorkService.settings!=null)
        {
            if (ClockWorkService.settings.getBoolean("pref_looging", false))
            {
                Log.i(TAG, m);
            }
            if (ClockWorkService.settings.getBoolean("pref_looging_file", false))
            {
                store(TAG, m);
            }
        }
        else
        {
            Log.i(TAG, m);
        }
    }

    public static void d(String TAG, String m)
    {
        if(ClockWorkService.settings!=null)
        {
            if (ClockWorkService.settings.getBoolean("pref_looging", false))
            {
                Log.d(TAG, m);
            }
            if (ClockWorkService.settings.getBoolean("pref_looging_file", false))
            {
                store(TAG, m);
            }
        }
        else
        {
            Log.d(TAG, m);
        }
    }

    public static void e(String TAG, String m)
    {
        if(ClockWorkService.settings!=null)
        {
            if (ClockWorkService.settings.getBoolean("pref_looging", false))
            {
                Log.e(TAG, m);
            }
            if (ClockWorkService.settings.getBoolean("pref_looging_file", false))
            {
                store(TAG, m);
            }
        }
        else
        {
            Log.e(TAG, m);
        }
    }

    public static void v(String TAG, String m)
    {
        if(ClockWorkService.settings!=null)
        {
            if (ClockWorkService.settings.getBoolean("pref_looging", false))
            {
                Log.v(TAG, m);
            }
            if (ClockWorkService.settings.getBoolean("pref_looging_file", false))
            {
                store(TAG, m);
            }
        }
        else
        {
            Log.v(TAG, m);
        }
    }

    public static void w(String TAG, String m)
    {
        if(ClockWorkService.settings!=null)
        {
            if (ClockWorkService.settings.getBoolean("pref_looging", false))
            {
                Log.w(TAG, m);
            }
            if (ClockWorkService.settings.getBoolean("pref_looging_file", false))
            {
                store(TAG, m);
            }
        }
        else
        {
            Log.w(TAG, m);
        }
    }

    public static void wtf(String TAG, String m)
    {
        if(ClockWorkService.settings!=null)
        {
            if (ClockWorkService.settings.getBoolean("pref_looging", false))
            {
                Log.wtf(TAG, m);
            }
            if (ClockWorkService.settings.getBoolean("pref_looging_file", false))
            {
                store(TAG, m);
            }
        }
        else
        {
            Log.wtf(TAG, m);
        }
    }

    private static boolean store(String TAG, String m)
    {
        DateTime d = new DateTime();
        String log="aaclog.txt";
        File Root = Environment.getExternalStorageDirectory();
        if(Root.canWrite())
        {
            File logFile = new File(Root, log);
            if (!logFile.exists())
            {
                try
                {
                    logFile.createNewFile();
                }
                catch (IOException e)
                {

                    e.printStackTrace();
                }
            }
            try
            {
                BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
                //BufferedWriter for performance, true to set append to file flag
                String logString = d.getDayOfMonth()+"-"+d.getMonthOfYear()+"-"+d.getYear()+" "+d.getHourOfDay()+":"+d.getMinuteOfHour()+":"+d.getSecondOfMinute()+"  "+TAG+" "+m+"\n";
                buf.append(logString);
                buf.close();
            }
            catch (IOException e)
            {

                e.printStackTrace();
            }
        }
        return true;
    }
}




Java Source Code List

de.lukeslog.alarmclock.MediaPlayer.MediaPlayerService.java
de.lukeslog.alarmclock.actions.ActionActivity.java
de.lukeslog.alarmclock.actions.ActionConfigBundle.java
de.lukeslog.alarmclock.actions.ActionManager.java
de.lukeslog.alarmclock.actions.AmbientAction.java
de.lukeslog.alarmclock.actions.CountdownActionConfigurationFragment.java
de.lukeslog.alarmclock.actions.CountdownAction.java
de.lukeslog.alarmclock.actions.EZControlHeatActionConfigurationFragment.java
de.lukeslog.alarmclock.actions.EZControlHeatAction.java
de.lukeslog.alarmclock.actions.EZControlPlugActionConfigurationFragment.java
de.lukeslog.alarmclock.actions.EZControlPlugAction.java
de.lukeslog.alarmclock.actions.MusicActionConfigurationFragment.java
de.lukeslog.alarmclock.actions.MusicAction.java
de.lukeslog.alarmclock.actions.PhilipsHueActionConfigurationFragment.java
de.lukeslog.alarmclock.actions.PhilipsHueAction.java
de.lukeslog.alarmclock.actions.SendMailActionFragment.java
de.lukeslog.alarmclock.actions.SendMailAction.java
de.lukeslog.alarmclock.actions.WebsiteActionConfigurationFragment.java
de.lukeslog.alarmclock.actions.WebsiteAction.java
de.lukeslog.alarmclock.ambientService.dropbox.DropBox.java
de.lukeslog.alarmclock.ambientService.lastfm.Scrobbler.java
de.lukeslog.alarmclock.ambientService.mail.BackgroundMail.java
de.lukeslog.alarmclock.ambientService.mail.Mail.java
de.lukeslog.alarmclock.ambientalarm.AmbientAlarmManager.java
de.lukeslog.alarmclock.ambientalarm.AmbientAlarm.java
de.lukeslog.alarmclock.datatabse.AmbientAlarmDatabase.java
de.lukeslog.alarmclock.datatabse.DatabaseConstants.java
de.lukeslog.alarmclock.main.ClockWorkService.java
de.lukeslog.alarmclock.main.NotificationManagement.java
de.lukeslog.alarmclock.main.Timable.java
de.lukeslog.alarmclock.startup.NotificationService.java
de.lukeslog.alarmclock.startup.ServiceStarter.java
de.lukeslog.alarmclock.startup.StartUp.java
de.lukeslog.alarmclock.support.AlarmClockConstants.java
de.lukeslog.alarmclock.support.AlarmState.java
de.lukeslog.alarmclock.support.Day.java
de.lukeslog.alarmclock.support.Logger.java
de.lukeslog.alarmclock.support.Radiostations.java
de.lukeslog.alarmclock.support.Settings.java
de.lukeslog.alarmclock.support.UISupport.java
de.lukeslog.alarmclock.teardown.Teardown.java
de.lukeslog.alarmclock.ui.ActionListAdapter.java
de.lukeslog.alarmclock.ui.AlarmClockMainActivity.java
de.lukeslog.alarmclock.ui.AlarmListAdapter.java
de.lukeslog.alarmclock.ui.AmbientAlarmActivity.java
de.lukeslog.alarmclock.ui.AmbientAlarmConfigurationActivity.java
de.lukeslog.alarmclock.ui.NewAmbientAction.java
de.lukeslog.alarmclock.ui.NewSettingsFragment.java
de.lukeslog.alarmclock.ui.SettingsActivity.java
org.json2.JSONArray.java
org.json2.JSONException.java
org.json2.JSONObject.java
org.json2.JSONString.java
org.json2.JSONStringer.java
org.json2.JSONTokener.java
org.json2.JSONWriter.java