Android Open Source - androidtestdebug Memory Log






From Project

Back to project page androidtestdebug.

License

The source code is released under:

MIT License

If you think the Android project androidtestdebug 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

import java.util.*;
//  ww  w  . j  a  va  2s  . c o  m
public class MemoryLog {
    private LogEntry[] _entries = null;
    private int _index = -1;
    private Object _lock = new Object();
    
    public void Init() {
  _entries = new LogEntry[1024];
    }
    
    public void Add(String msg, Object data) {
  int index = 0;
  synchronized ( _lock ) {
      index = ++_index % 1024;
  }
  
  LogEntry entry = new LogEntry();
  entry.Data = data;
  entry.Message = msg;
  entry.Time = new Date();
  Thread thread = Thread.currentThread();
  entry.ThreadId = thread.getId();
  entry.ThreadName = thread.getName();
  
  _entries[index] = entry;
    }

    public void PrintLog() {
  int idx = _index % 1024;
  for ( int i = 0; i < idx; ++i ) {
      LogEntry entry = _entries[i];
      System.out.println(String.format("Thread [%1$d - %2$s@%3$s]: %4$s %5$s",  entry.ThreadId,
               entry.ThreadName,
               entry.Time.toString(),
               entry.Message,
               entry.Data.toString()));
  }
    }

    static class LogEntry {
  public long ThreadId;
  public String ThreadName;
  public String Message;
  public Object Data;
  public Date Time;
    }
}




Java Source Code List

.????2.java
.ClbDemoClass.java
.DataDrivenDemoTest.java
.DeadLockDemo.java
.Dekker.java
.FirstDemo.java
.FirstDemo.java
.MemoryLog.java
.RaceConditionFix.java
.RaceCondition.java
.Sample1Test.java
.Sample1.java
.Sample2Test.java
.Sample2.java
.SampleSuite.java
bpdemo.BpDemo.java
bpdemo.ClbDemoClass.java
.bpdemo.java
cc.iqa.iquery.mr.By.java
cc.iqa.iquery.mr.ControlHierarchy.java
cc.iqa.iquery.mr.Plugin.java
cc.iqa.iquery.mr.QueryableDevice.java
chapter11.HelloWorld.java
com.android.example.spinner.SpinnerActivity.java
com.example.android.hcgallery.CameraFragment.java
com.example.android.hcgallery.CameraFragment.java
com.example.android.hcgallery.CameraFragment.java
com.example.android.hcgallery.CameraSample.java
com.example.android.hcgallery.CameraSample.java
com.example.android.hcgallery.CameraSample.java
com.example.android.hcgallery.ContentFragment.java
com.example.android.hcgallery.ContentFragment.java
com.example.android.hcgallery.ContentFragment.java
com.example.android.hcgallery.DirectoryCategory.java
com.example.android.hcgallery.DirectoryCategory.java
com.example.android.hcgallery.DirectoryCategory.java
com.example.android.hcgallery.DirectoryEntry.java
com.example.android.hcgallery.DirectoryEntry.java
com.example.android.hcgallery.DirectoryEntry.java
com.example.android.hcgallery.Directory.java
com.example.android.hcgallery.Directory.java
com.example.android.hcgallery.Directory.java
com.example.android.hcgallery.FitCenterFrameLayout.java
com.example.android.hcgallery.FitCenterFrameLayout.java
com.example.android.hcgallery.FitCenterFrameLayout.java
com.example.android.hcgallery.INotifyDirectoryChanged.java
com.example.android.hcgallery.INotifyDirectoryChanged.java
com.example.android.hcgallery.INotifyDirectoryChanged.java
com.example.android.hcgallery.MainActivity.java
com.example.android.hcgallery.MainActivity.java
com.example.android.hcgallery.MainActivity.java
com.example.android.hcgallery.TitlesFragment.java
com.example.android.hcgallery.TitlesFragment.java
com.example.android.hcgallery.TitlesFragment.java
com.example.tests.FirstDemo.java
.gcdemo.java
.gcdemo.java
.????.java
.???????????.java
temp.CaseErrorException.java
temp.Constants.java
temp.Login2blogTest.java
temp.UserOperationsHelper.java