1 package ai.suanzi.rtmpclient;
3 import android.content.Intent;
5 import org.apache.log4j.Level;
6 import org.apache.log4j.Logger;
7 import de.mindpipe.android.logging.log4j.LogConfigurator;
8 import java.util.Properties;
9 import javax.mail.Transport;
10 import javax.mail.Session;
11 import javax.mail.internet.MimeMessage;
12 import javax.mail.internet.InternetAddress;
13 import java.util.Date;
14 import android.os.StrictMode;
18 public class LogUtil {
20 private static Logger gLogger;
21 private static final String FILE_NAME = "log.txt";
22 private static final long MAX_SIZE = 1024 * 1024 * 10; // 10M
23 private static String logFile = "";
26 public static void config(File dir) {
28 final LogConfigurator logConfigurator = new LogConfigurator();
29 //String fname = getExternalFilesDir(null) + File.separator + "log.txt";
30 logFile = dir + File.separator + FILE_NAME;
31 logConfigurator.setFileName(logFile);
32 logConfigurator.setRootLevel(Level.DEBUG);
33 logConfigurator.setLevel("org.apache", Level.ERROR);
34 logConfigurator.setMaxFileSize(MAX_SIZE);
35 logConfigurator.configure();
36 gLogger = Logger.getLogger("LogUtil");
37 gLogger.error("#######################################");
38 gLogger.debug("Log file is located at: " + logFile);
40 } catch (Exception e){
46 int SDK_INT = android.os.Build.VERSION.SDK_INT;
49 StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
51 StrictMode.setThreadPolicy(policy);
57 } catch (Exception e) {
70 // public void sendEmail()
73 // private static final int PICK_FROM_GALLERY = 101;
80 // final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
81 // emailIntent.setType("plain/text");
82 // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "Email" });
83 // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
85 // emailIntent.putExtra(Intent.EXTRA_STREAM, URI);
87 // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is a message");
88 // this.startActivity(Intent.createChooser(emailIntent,"Sending email..."));
90 // catch (Throwable t)
92 // Toast.makeText(this, "Request failed try again: " + t.toString(),Toast.LENGTH_LONG).show();
95 // public void openFolder()
97 // Intent intent = new Intent();
98 // intent.setType("image/*");
99 // intent.setAction(Intent.ACTION_GET_CONTENT);
100 // intent.putExtra("return-data", true);
101 // startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_GALLERY);
104 // public static sendLogs(){
108 // public void SendLoagcatMail(){
110 // // save logcat in file
111 // /*File outputFile = new File(Environment.getExternalStorageDirectory(),
114 // Runtime.getRuntime().exec(
115 // "logcat -f " + outputFile.getAbsolutePath());
116 // } catch (IOException e) {
117 // // TODO Auto-generated catch block
118 // e.printStackTrace();
120 // String fname = getExternalFilesDir(null) + File.separator + "log.txt";
122 // File logfile = new File(fname);
124 // //send file using email
125 // Intent emailIntent = new Intent(Intent.ACTION_SEND);
126 // emailIntent.setType("vnd.android.cursor.dir/email");
127 // String to[] = {"seudut@gmail.com"};
128 // emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
130 // emailIntent.putExtra(Intent.EXTRA_STREAM, logfile.getAbsolutePath());
131 // // the mail subject
132 // emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
133 // startActivity(Intent.createChooser(emailIntent , "Send email..."));