Skip to content

Commit

Permalink
minor UI issues 3 - logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Paku- committed Jan 27, 2014
1 parent 5bd8cdb commit 761a8ed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 19 additions & 5 deletions MavLinkHUB/src/com/paku/mavlinkhub/utils/HUBLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public void sysLog(String string) {
// syslog write
try {
synchronized (inMemSysLogBuffer) {
mFileSysLogStream.write(tempStr.getBytes(), 0, tempStr.length());
if (hub.prefs.getBoolean("pref_log_system", true)) {
mFileSysLogStream.write(tempStr.getBytes(), 0, tempStr.length());
}
inMemSysLogBuffer.append(tempStr);
}
HUBGlobals.sendAppMsg(APP_STATE.MSG_DATA_UPDATE_SYSLOG);
Expand All @@ -82,9 +84,10 @@ public void byteLog(MSG_SOURCE direction, ByteBuffer buffer) {
// log only Drone data to the bytelog file
if (null != buffer && direction == MSG_SOURCE.FROM_DRONE) {
synchronized (inMemByteLogBuffer) {

try {
mFileByteLogStream.write(buffer.array(), 0, buffer.limit());
if (hub.prefs.getBoolean("pref_log_mavlink_byte", true)) {
mFileByteLogStream.write(buffer.array(), 0, buffer.limit());
}
}
catch (IOException e) {
Log.d(TAG, "[byteLog] " + e.getMessage());
Expand All @@ -101,7 +104,6 @@ public void byteLog(MSG_SOURCE direction, ByteBuffer buffer) {
}
}

// Log.d(TAG, "[byteLog] " + e1.getMessage());
public void restartByteLog() {

byteLogFile = new File(getLoggerStorageLocation(null), getLoggerFileName("byte"));
Expand All @@ -112,7 +114,7 @@ public void restartByteLog() {
Log.d(TAG, e.getMessage());
}

inMemSysLogBuffer.delete(0, inMemByteLogBuffer.length());
inMemByteLogBuffer.delete(0, inMemByteLogBuffer.length());

}

Expand All @@ -139,11 +141,23 @@ private String getLoggerFileName(String name) {
}

public void stopByteLog() {

stopLog(mFileByteLogStream);

if (!hub.prefs.getBoolean("pref_log_mavlink_byte", true)) {
byteLogFile.delete();
}

}

public void stopSysLog() {

stopLog(mFileSysLogStream);

if (!hub.prefs.getBoolean("pref_log_system", true)) {
sysLogFile.delete();
}

}

private void stopLog(BufferedOutputStream stream) {
Expand Down
2 changes: 2 additions & 0 deletions MavLinkHUB/tmp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Drone link
logWriter.write(receivedPacket.encodePacket());


pref

dev_add
menu
remove
Expand Down

0 comments on commit 761a8ed

Please sign in to comment.