Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
client/react-native/android/app/src/main/java/chat/berty/core/Level.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package chat.berty.core; | ||
|
||
public enum Level | ||
{ | ||
DEBUG("DEBUG"), | ||
INFO("INFO"), | ||
WARN("WARN"), | ||
ERROR("ERROR"), | ||
PANIC("PANIC"), | ||
DPANIC("DPANIC"), | ||
FATAL("FATAL"), | ||
UNKNOW("UNKNOW"); | ||
|
||
private final String level; | ||
|
||
Level(final String level) { | ||
this.level = level; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return level; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
client/react-native/android/app/src/main/java/chat/berty/core/Logger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package chat.berty.core; | ||
|
||
import android.util.Log; | ||
|
||
public class Logger implements core.Logger { | ||
boolean isEnabled = true; | ||
String subsytem = "logger"; | ||
|
||
public Logger(String subsytem) { | ||
this.subsytem = subsytem; | ||
} | ||
|
||
// @TODO: implement this | ||
@Override | ||
public boolean levelEnabler(String level) { | ||
return this.isEnabled; | ||
} | ||
|
||
public void format(Level level, String namespace, String format, Object... args) { | ||
final String message = String.format(format, args); | ||
try { | ||
this.log(level.toString(), namespace, message); | ||
} catch (Exception e) { | ||
final String tag = this.subsytem + "." + namespace; | ||
Log.e(tag, "Unable to use logger: " + e.getMessage()); | ||
Log.e(tag, message); | ||
} | ||
} | ||
|
||
@Override | ||
public void log(String level, String namespace, String message) throws Exception { | ||
final Level currentLevel = Level.valueOf(level); | ||
final String tag = this.subsytem + "." + namespace; | ||
|
||
switch(currentLevel) { | ||
case DEBUG: | ||
Log.d(tag, message); | ||
break; | ||
case INFO: | ||
Log.i(tag, message); | ||
break; | ||
case WARN: | ||
Log.w(tag, message); | ||
break; | ||
case ERROR: | ||
Log.e(tag, message); | ||
break; | ||
case PANIC: | ||
Log.wtf(tag, message); | ||
break; | ||
case DPANIC: | ||
Log.wtf(tag, message); | ||
break; | ||
case FATAL: | ||
Log.wtf(tag, message); | ||
break; | ||
case UNKNOW: | ||
Log.i(tag, message); | ||
break; | ||
default: | ||
Log.i(tag, message); | ||
break; | ||
|
||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters