#!/system/bin/sh
# Dump log to file, updated by jing.wang
if [ "$1" != "" ]; then
	ps >> $1
	ps -t -p >> $1
	echo " " >> $1
  cat /proc/meminfo >> $1
  cat /proc/vmstat >> $1
  cat /proc/slabinfo >> $1
  cat /proc/zoneinfo >> $1
  cat /proc/net/route >> $1
  echo "wakelocks:" >> $1
  cat /proc/wakelocks >> $1
  netcfg >> $1
	getprop >> $1
	echo "wake_lock:" >> $1
	cat /sys/power/wake_lock >> $1
	echo " " >> $1
	echo "logcat:" >> $1
	logcat -f $1 -d -v time
	echo " " >> $1
	echo "logcat: radio" >> $1
	logcat -b radio -f $1 -d -v time
	echo " " >> $1
	echo "logcat: system" >> $1
	logcat -b system -f $1 -d -v time
	echo " " >> $1
	echo "kernel message:" >> $1
	dmesg >> $1
	gzip $1
fi

#CP /data/log to SDCARD, By Jim
SDCARD_DEBUG_FLAG="/marvell/tel/NVM/yuhuatel/sdcard_debug"

if [ -e $SDCARD_DEBUG_FLAG ] &&  [ `grep -c sdcard /proc/mounts`  == 2 ]; then

    TIME=`date "+%Y-%m-%d-%H-%M-%S"`
    INSTANT_LOG_SAVED_DIR="INSTANT-LOG-$TIME"

    busybox mkdir /sdcard/$INSTANT_LOG_SAVED_DIR
    busybox cp -rf /data/log /sdcard/$INSTANT_LOG_SAVED_DIR
fi
