-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.java
More file actions
57 lines (47 loc) · 1.6 KB
/
Logger.java
File metadata and controls
57 lines (47 loc) · 1.6 KB
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
54
55
56
57
package com.partharaj.utils;
import android.os.Environment;
import android.util.Log;
import com.partharaj.BuildConfig;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Logger {
public static void log(Class c, String message) {
if (BuildConfig.DEBUG) {
Log.e(c.getClass().getName(), message);
}
}
public static void log(String tag, String message) {
if (BuildConfig.DEBUG) {
Log.e(tag, message);
}
}
public static void log(String tag, String message, Throwable tr) {
if (BuildConfig.DEBUG) {
Log.e(tag, message);
}
}
public static void log(String message) {
if (BuildConfig.DEBUG) {
Log.e(BuildConfig.APPLICATION_ID, message);
}
}
public static void logDump(String message) {
logDump("", message);
}
public static void logDump(String tag, String message) {
if (BuildConfig.DEBUG) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String now = sdf.format(new Date());
message = now + " " + tag + "\n" + message + "\n\n=====================================\n\n";
FileOutputStream os = new FileOutputStream(new File(Environment.getExternalStorageDirectory(), "pdLog.txt"), true);
os.write(message.getBytes(), 0, message.length());
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}