mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
refactor(logger): rename ILogger.Priority to ILogger.Level
This commit is contained in:
@@ -29,14 +29,14 @@ import com.itsaky.androidide.utils.ILogger
|
|||||||
class IDELogFragment : LogViewFragment() {
|
class IDELogFragment : LogViewFragment() {
|
||||||
|
|
||||||
private var logListener: ILogger.LogListener? =
|
private var logListener: ILogger.LogListener? =
|
||||||
ILogger.LogListener { priority, tag, message ->
|
ILogger.LogListener { level, tag, message ->
|
||||||
if (message.contains("\n")) {
|
if (message.contains("\n")) {
|
||||||
val split = message.split("\n").toTypedArray()
|
val split = message.split("\n").toTypedArray()
|
||||||
for (line in split) {
|
for (line in split) {
|
||||||
logLine(priority, tag, line)
|
logLine(level, tag, line)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logLine(priority, tag, message)
|
logLine(level, tag, message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.itsaky.androidide.editor.schemes.IDEColorSchemeProvider
|
|||||||
import com.itsaky.androidide.fragments.EmptyStateFragment
|
import com.itsaky.androidide.fragments.EmptyStateFragment
|
||||||
import com.itsaky.androidide.models.LogLine
|
import com.itsaky.androidide.models.LogLine
|
||||||
import com.itsaky.androidide.utils.ILogger
|
import com.itsaky.androidide.utils.ILogger
|
||||||
import com.itsaky.androidide.utils.ILogger.Priority
|
import com.itsaky.androidide.utils.ILogger.Level
|
||||||
import com.itsaky.androidide.utils.jetbrainsMono
|
import com.itsaky.androidide.utils.jetbrainsMono
|
||||||
import io.github.rosemoe.sora.widget.style.CursorAnimator
|
import io.github.rosemoe.sora.widget.style.CursorAnimator
|
||||||
import java.util.concurrent.ArrayBlockingQueue
|
import java.util.concurrent.ArrayBlockingQueue
|
||||||
@@ -195,8 +195,8 @@ abstract class LogViewFragment :
|
|||||||
|
|
||||||
abstract fun isSimpleFormattingEnabled(): Boolean
|
abstract fun isSimpleFormattingEnabled(): Boolean
|
||||||
|
|
||||||
protected open fun logLine(priority: Priority, tag: String, message: String) {
|
protected open fun logLine(level: Level, tag: String, message: String) {
|
||||||
val line = LogLine.obtain(priority, tag, message)
|
val line = LogLine.obtain(level, tag, message)
|
||||||
appendLog(line)
|
appendLog(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
|
|||||||
|
|
||||||
override fun logMessage(params: LogMessageParams) {
|
override fun logMessage(params: LogMessageParams) {
|
||||||
val line = params.toLogLine()
|
val line = params.toLogLine()
|
||||||
serverLogger.log(line.priority, line.formattedTagAndMessage())
|
serverLogger.log(line.level, line.formattedTagAndMessage())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun logOutput(line: String) {
|
override fun logOutput(line: String) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ AndroidIDE v2.0.0-beta is here with new features, improvements, bug fixes and a
|
|||||||
- `Import orderer`: Organizes the imports. Thanks to @MrIkso (#180).
|
- `Import orderer`: Organizes the imports. Thanks to @MrIkso (#180).
|
||||||
- XML Code formatter. Thanks to @MrIkso (#182).
|
- XML Code formatter. Thanks to @MrIkso (#182).
|
||||||
- New Gradle command line options: `--build-cache` and `--offline`. Thanks to @MrIkso (#180).
|
- New Gradle command line options: `--build-cache` and `--offline`. Thanks to @MrIkso (#180).
|
||||||
- Highlight IDE logs based on the log line priority.
|
- Highlight IDE logs based on the log line level.
|
||||||
- Option to share Build Output, App log and IDE logs as text file.
|
- Option to share Build Output, App log and IDE logs as text file.
|
||||||
- Syntax highlighting for Kotlin and C/C++ language. Thanks to @MrIkso (#196).
|
- Syntax highlighting for Kotlin and C/C++ language. Thanks to @MrIkso (#196).
|
||||||
- Highlight hex color code in string literals. Thanks to @MrIkso (#209).
|
- Highlight hex color code in string literals. Thanks to @MrIkso (#209).
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Following issues have been fixed in this release :
|
|||||||
- Hide tab layout when no files are opened (#330).
|
- Hide tab layout when no files are opened (#330).
|
||||||
- Do not show full error message when layout inflation fails (#274).
|
- Do not show full error message when layout inflation fails (#274).
|
||||||
- Use Storage Access Framework (SAF) for picking directories.
|
- Use Storage Access Framework (SAF) for picking directories.
|
||||||
- 'Preview layout' item now has more priority than other options menu icons (#243).
|
- 'Preview layout' item now has more level than other options menu icons (#243).
|
||||||
- Do not show editor actions window when in search mode.
|
- Do not show editor actions window when in search mode.
|
||||||
- Use relative padding in TreeView to support RTL layouts.
|
- Use relative padding in TreeView to support RTL layouts.
|
||||||
- Updated crash report. By @AndreyKozhev (#460).
|
- Updated crash report. By @AndreyKozhev (#460).
|
||||||
|
|||||||
@@ -35,5 +35,5 @@ _No notes_
|
|||||||
## Improvements
|
## Improvements
|
||||||
|
|
||||||
- Improved colors in editor windows.
|
- Improved colors in editor windows.
|
||||||
- Signture help window is now given more priority over the diagnostics window. This means, if the signature help window is visible to the user, the diagnostics window will not be shown.
|
- Signture help window is now given more level over the diagnostics window. This means, if the signature help window is visible to the user, the diagnostics window will not be shown.
|
||||||
- The IDE now releases some unnecessary resources when a file is deleted or renamed.
|
- The IDE now releases some unnecessary resources when a file is deleted or renamed.
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
(time) @err.time
|
(time) @err.time
|
||||||
(pid) @err.pid
|
(pid) @err.pid
|
||||||
(tid) @err.tid
|
(tid) @err.tid
|
||||||
(priority) @err.priority
|
(level) @err.level
|
||||||
(tag) @err.tag
|
(tag) @err.tag
|
||||||
(message) @err.msg
|
(message) @err.msg
|
||||||
(#match? @err.priority "E")
|
(#match? @err.level "E")
|
||||||
)
|
)
|
||||||
|
|
||||||
(log_line
|
(log_line
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
(time) @warn.time
|
(time) @warn.time
|
||||||
(pid) @warn.pid
|
(pid) @warn.pid
|
||||||
(tid) @warn.tid
|
(tid) @warn.tid
|
||||||
(priority) @warn.priority
|
(level) @warn.level
|
||||||
(tag) @warn.tag
|
(tag) @warn.tag
|
||||||
(message) @warn.msg
|
(message) @warn.msg
|
||||||
(#match? @warn.priority "W")
|
(#match? @warn.level "W")
|
||||||
)
|
)
|
||||||
|
|
||||||
(log_line
|
(log_line
|
||||||
@@ -27,10 +27,10 @@
|
|||||||
(time) @info.time
|
(time) @info.time
|
||||||
(pid) @info.pid
|
(pid) @info.pid
|
||||||
(tid) @info.tid
|
(tid) @info.tid
|
||||||
(priority) @info.priority
|
(level) @info.level
|
||||||
(tag) @info.tag
|
(tag) @info.tag
|
||||||
(message) @info.msg
|
(message) @info.msg
|
||||||
(#match? @info.priority "I")
|
(#match? @info.level "I")
|
||||||
)
|
)
|
||||||
|
|
||||||
(log_line
|
(log_line
|
||||||
@@ -38,10 +38,10 @@
|
|||||||
(time) @debug.time
|
(time) @debug.time
|
||||||
(pid) @debug.pid
|
(pid) @debug.pid
|
||||||
(tid) @debug.tid
|
(tid) @debug.tid
|
||||||
(priority) @debug.priority
|
(level) @debug.level
|
||||||
(tag) @debug.tag
|
(tag) @debug.tag
|
||||||
(message) @debug.msg
|
(message) @debug.msg
|
||||||
(#match? @debug.priority "D")
|
(#match? @debug.level "D")
|
||||||
)
|
)
|
||||||
|
|
||||||
(log_line
|
(log_line
|
||||||
@@ -49,43 +49,43 @@
|
|||||||
(time) @verbose.time
|
(time) @verbose.time
|
||||||
(pid) @verbose.pid
|
(pid) @verbose.pid
|
||||||
(tid) @verbose.tid
|
(tid) @verbose.tid
|
||||||
(priority) @verbose.priority
|
(level) @verbose.level
|
||||||
(tag) @verbose.tag
|
(tag) @verbose.tag
|
||||||
(message) @verbose.msg
|
(message) @verbose.msg
|
||||||
(#match? @verbose.priority "V")
|
(#match? @verbose.level "V")
|
||||||
)
|
)
|
||||||
|
|
||||||
(ide_log_line
|
(ide_log_line
|
||||||
(ide_tag) @err.tag
|
(ide_tag) @err.tag
|
||||||
(priority) @err.priority
|
(level) @err.level
|
||||||
(message) @err.msg
|
(message) @err.msg
|
||||||
(#match? @err.priority "E")
|
(#match? @err.level "E")
|
||||||
)
|
)
|
||||||
|
|
||||||
(ide_log_line
|
(ide_log_line
|
||||||
(ide_tag) @warn.tag
|
(ide_tag) @warn.tag
|
||||||
(priority) @warn.priority
|
(level) @warn.level
|
||||||
(message) @warn.msg
|
(message) @warn.msg
|
||||||
(#match? @warn.priority "W")
|
(#match? @warn.level "W")
|
||||||
)
|
)
|
||||||
|
|
||||||
(ide_log_line
|
(ide_log_line
|
||||||
(ide_tag) @info.tag
|
(ide_tag) @info.tag
|
||||||
(priority) @info.priority
|
(level) @info.level
|
||||||
(message) @info.msg
|
(message) @info.msg
|
||||||
(#match? @info.priority "I")
|
(#match? @info.level "I")
|
||||||
)
|
)
|
||||||
|
|
||||||
(ide_log_line
|
(ide_log_line
|
||||||
(ide_tag) @debug.tag
|
(ide_tag) @debug.tag
|
||||||
(priority) @debug.priority
|
(level) @debug.level
|
||||||
(message) @debug.msg
|
(message) @debug.msg
|
||||||
(#match? @debug.priority "D")
|
(#match? @debug.level "D")
|
||||||
)
|
)
|
||||||
|
|
||||||
(ide_log_line
|
(ide_log_line
|
||||||
(ide_tag) @verbose.tag
|
(ide_tag) @verbose.tag
|
||||||
(priority) @verbose.priority
|
(level) @verbose.level
|
||||||
(message) @verbose.msg
|
(message) @verbose.msg
|
||||||
(#match? @verbose.priority "V")
|
(#match? @verbose.level "V")
|
||||||
)
|
)
|
||||||
@@ -31,8 +31,8 @@ public class AndroidLogger extends ILogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLog(Priority priority, String message) {
|
protected void doLog(Level level, String message) {
|
||||||
switch (priority) {
|
switch (level) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
Log.e(TAG, message);
|
Log.e(TAG, message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -97,45 +97,45 @@ public abstract class ILogger {
|
|||||||
* @return This logger instance.
|
* @return This logger instance.
|
||||||
*/
|
*/
|
||||||
public ILogger error(Object... messages) {
|
public ILogger error(Object... messages) {
|
||||||
return log(Priority.ERROR, messages);
|
return log(Level.ERROR, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log messages with the given priority.
|
* Log messages with the given log level.
|
||||||
*
|
*
|
||||||
* @param priority The priority of the log messages.
|
* @param level The log level of the messages.
|
||||||
* @param messages The messages to log.
|
* @param messages The messages to log.
|
||||||
* @return This logger instance.
|
* @return This logger instance.
|
||||||
*/
|
*/
|
||||||
public ILogger log(Priority priority, Object... messages) {
|
public ILogger log(Level level, Object... messages) {
|
||||||
logAndNotify(priority, generateMessage(messages));
|
logAndNotify(level, generateMessage(messages));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logAndNotify(Priority priority, String msg) {
|
private void logAndNotify(Level level, String msg) {
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
// logger is disabled
|
// logger is disabled
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
doLog(priority, msg);
|
doLog(level, msg);
|
||||||
for (final var listener : logListeners) {
|
for (final var listener : logListeners) {
|
||||||
listener.log(priority, TAG, msg);
|
listener.log(level, TAG, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log the message to an appropriate stream where the user can see the log messages.
|
* Log the message to an appropriate stream where the user can see the log messages.
|
||||||
*
|
*
|
||||||
* @param priority The priority for this log message.
|
* @param level The log level for this message.
|
||||||
* @param message The full generated message for this log. Might contain new lines.
|
* @param message The full generated message for this log. Might contain new lines.
|
||||||
* @see ILogger.Priority#DEBUG
|
* @see Level#DEBUG
|
||||||
* @see ILogger.Priority#ERROR
|
* @see Level#ERROR
|
||||||
* @see ILogger.Priority#WARNING
|
* @see Level#WARNING
|
||||||
* @see ILogger.Priority#VERBOSE
|
* @see Level#VERBOSE
|
||||||
* @see ILogger.Priority#INFO
|
* @see Level#INFO
|
||||||
*/
|
*/
|
||||||
protected abstract void doLog(Priority priority, String message);
|
protected abstract void doLog(Level level, String message);
|
||||||
|
|
||||||
protected String generateMessage(Object... messages) {
|
protected String generateMessage(Object... messages) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -159,7 +159,7 @@ public abstract class ILogger {
|
|||||||
* @return This logger instance.
|
* @return This logger instance.
|
||||||
*/
|
*/
|
||||||
public ILogger warn(Object... messages) {
|
public ILogger warn(Object... messages) {
|
||||||
return log(Priority.WARNING, messages);
|
return log(Level.WARNING, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,7 +169,7 @@ public abstract class ILogger {
|
|||||||
* @return This logger instance.
|
* @return This logger instance.
|
||||||
*/
|
*/
|
||||||
public ILogger verbose(Object... messages) {
|
public ILogger verbose(Object... messages) {
|
||||||
return log(Priority.VERBOSE, messages);
|
return log(Level.VERBOSE, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,7 +179,7 @@ public abstract class ILogger {
|
|||||||
* @return This logger instance.
|
* @return This logger instance.
|
||||||
*/
|
*/
|
||||||
public ILogger info(Object... messages) {
|
public ILogger info(Object... messages) {
|
||||||
return log(Priority.INFO, messages);
|
return log(Level.INFO, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,7 +196,7 @@ public abstract class ILogger {
|
|||||||
* @return This logger instance.
|
* @return This logger instance.
|
||||||
*/
|
*/
|
||||||
public ILogger debug(Object... messages) {
|
public ILogger debug(Object... messages) {
|
||||||
return log(Priority.DEBUG, messages);
|
return log(Level.DEBUG, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -234,9 +234,9 @@ public abstract class ILogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logging priority.
|
* Logging level.
|
||||||
*/
|
*/
|
||||||
public enum Priority {
|
public enum Level {
|
||||||
|
|
||||||
DEBUG('D'),
|
DEBUG('D'),
|
||||||
WARNING('W'),
|
WARNING('W'),
|
||||||
@@ -244,21 +244,21 @@ public abstract class ILogger {
|
|||||||
INFO('I'),
|
INFO('I'),
|
||||||
VERBOSE('V');
|
VERBOSE('V');
|
||||||
|
|
||||||
public final char priorityChar;
|
public final char levelChar;
|
||||||
|
|
||||||
Priority(char priorityChar) {
|
Level(char levelChar) {
|
||||||
this.priorityChar = priorityChar;
|
this.levelChar = levelChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Priority forChar(char c) {
|
public static Level forChar(char c) {
|
||||||
c = Character.toUpperCase(c);
|
c = Character.toUpperCase(c);
|
||||||
for (Priority value : values()) {
|
for (Level value : values()) {
|
||||||
if (value.priorityChar == c) {
|
if (value.levelChar == c) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException("Invalid priority char " + c);
|
throw new IllegalArgumentException("Invalid level char " + c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +267,6 @@ public abstract class ILogger {
|
|||||||
*/
|
*/
|
||||||
public interface LogListener {
|
public interface LogListener {
|
||||||
|
|
||||||
void log(Priority priority, String tag, String message);
|
void log(Level level, String tag, String message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ public class JvmLogger extends ILogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLog(Priority priority, String message) {
|
protected void doLog(Level level, String message) {
|
||||||
if (interceptor != null) {
|
if (interceptor != null) {
|
||||||
interceptor.onLog(priority, TAG, message);
|
interceptor.onLog(level, TAG, message);
|
||||||
} else {
|
} else {
|
||||||
System.err.printf(
|
System.err.printf(
|
||||||
"%-25s %-2s %s%n",
|
"%-25s %-2s %s%n",
|
||||||
trimTagIfNeeded(TAG, 25),
|
trimTagIfNeeded(TAG, 25),
|
||||||
priority.priorityChar,
|
level.levelChar,
|
||||||
message
|
message
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,6 @@ public class JvmLogger extends ILogger {
|
|||||||
|
|
||||||
public interface LogInterceptor {
|
public interface LogInterceptor {
|
||||||
|
|
||||||
void onLog(Priority priority, String tag, String message);
|
void onLog(Level level, String tag, String message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5445,8 +5445,8 @@
|
|||||||
<p>Only a single non-rectangular clip can be applied on a View at any time. Circular
|
<p>Only a single non-rectangular clip can be applied on a View at any time. Circular
|
||||||
clips from a
|
clips from a
|
||||||
{@link android.view.ViewAnimationUtils#createCircularReveal(View, int, int, float,
|
{@link android.view.ViewAnimationUtils#createCircularReveal(View, int, int, float,
|
||||||
float)} circular reveal animation take priority over Outline clipping, and child
|
float)} circular reveal animation take level over Outline clipping, and child
|
||||||
Outline clipping takes priority over Outline clipping done by a parent.
|
Outline clipping takes level over Outline clipping done by a parent.
|
||||||
<p>Note that this flag will only be respected if the View's Outline returns true from
|
<p>Note that this flag will only be respected if the View's Outline returns true from
|
||||||
{@link android.graphics.Outline#canClip()}. -->
|
{@link android.graphics.Outline#canClip()}. -->
|
||||||
<attr
|
<attr
|
||||||
@@ -10650,8 +10650,8 @@
|
|||||||
name="bottom_to_top"
|
name="bottom_to_top"
|
||||||
value="0x2" />
|
value="0x2" />
|
||||||
</attr>
|
</attr>
|
||||||
<!-- Priority of the rows and columns. When the priority is none,
|
<!-- Priority of the rows and columns. When the level is none,
|
||||||
both rows and columns have the same priority. When the priority is
|
both rows and columns have the same level. When the level is
|
||||||
column, the animations will be applied on the columns first. The same
|
column, the animations will be applied on the columns first. The same
|
||||||
goes for rows. -->
|
goes for rows. -->
|
||||||
<attr name="directionPriority">
|
<attr name="directionPriority">
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
var tid: String? = null
|
var tid: String? = null
|
||||||
var tag: String? = null
|
var tag: String? = null
|
||||||
var message: String? = null
|
var message: String? = null
|
||||||
var priority: ILogger.Priority? = null
|
var level: ILogger.Level? = null
|
||||||
var formatted = false
|
var formatted = false
|
||||||
|
|
||||||
// For JSONRpc and Recyclable
|
// For JSONRpc and Recyclable
|
||||||
@@ -40,7 +40,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
|
|
||||||
fun toSimpleString(): String {
|
fun toSimpleString(): String {
|
||||||
return if (formatted) String.format(
|
return if (formatted) String.format(
|
||||||
"%-25s %-2s %s", LogTagUtils.trimTagIfNeeded(tag, 25), priority?.priorityChar ?: 'U',
|
"%-25s %-2s %s", LogTagUtils.trimTagIfNeeded(tag, 25), level?.levelChar ?: 'U',
|
||||||
message) else unformatted!!
|
message) else unformatted!!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
time = null
|
time = null
|
||||||
date = null
|
date = null
|
||||||
unformatted = null
|
unformatted = null
|
||||||
priority = ILogger.Priority.DEBUG
|
level = ILogger.Level.DEBUG
|
||||||
formatted = false
|
formatted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return if (formatted) String.format(
|
return if (formatted) String.format(
|
||||||
"%s %s %s %s %-2s %-25s %s",
|
"%s %s %s %s %-2s %-25s %s",
|
||||||
date, time, pid, tid, priority?.priorityChar ?: 'U', LogTagUtils.trimTagIfNeeded(tag, 25),
|
date, time, pid, tid, level?.levelChar ?: 'U', LogTagUtils.trimTagIfNeeded(tag, 25),
|
||||||
message) else unformatted!!
|
message) else unformatted!!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
if (tid != other.tid) return false
|
if (tid != other.tid) return false
|
||||||
if (tag != other.tag) return false
|
if (tag != other.tag) return false
|
||||||
if (message != other.message) return false
|
if (message != other.message) return false
|
||||||
if (priority != other.priority) return false
|
if (level != other.level) return false
|
||||||
if (formatted != other.formatted) return false
|
if (formatted != other.formatted) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@@ -98,7 +98,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
result = 31 * result + (tid?.hashCode() ?: 0)
|
result = 31 * result + (tid?.hashCode() ?: 0)
|
||||||
result = 31 * result + (tag?.hashCode() ?: 0)
|
result = 31 * result + (tag?.hashCode() ?: 0)
|
||||||
result = 31 * result + (message?.hashCode() ?: 0)
|
result = 31 * result + (message?.hashCode() ?: 0)
|
||||||
result = 31 * result + (priority?.hashCode() ?: 0)
|
result = 31 * result + (level?.hashCode() ?: 0)
|
||||||
result = 31 * result + formatted.hashCode()
|
result = 31 * result + formatted.hashCode()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -114,10 +114,10 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun obtain(priority: ILogger.Priority?, tag: String?, message: String?,
|
fun obtain(level: ILogger.Level?, tag: String?, message: String?,
|
||||||
formatted: Boolean = true): LogLine {
|
formatted: Boolean = true): LogLine {
|
||||||
val logLine = logLinePool.obtain()
|
val logLine = logLinePool.obtain()
|
||||||
logLine.priority = priority
|
logLine.level = level
|
||||||
logLine.tag = tag
|
logLine.tag = tag
|
||||||
logLine.message = message
|
logLine.message = message
|
||||||
logLine.formatted = formatted
|
logLine.formatted = formatted
|
||||||
@@ -132,7 +132,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
|||||||
val logLine = logLinePool.obtain()
|
val logLine = logLinePool.obtain()
|
||||||
try {
|
try {
|
||||||
val split = log.split("\\s".toRegex(), limit = 7).toTypedArray()
|
val split = log.split("\\s".toRegex(), limit = 7).toTypedArray()
|
||||||
logLine.priority = ILogger.Priority.forChar(split[4][0])
|
logLine.level = ILogger.Level.forChar(split[4][0])
|
||||||
logLine.date = split[0]
|
logLine.date = split[0]
|
||||||
logLine.time = split[1] // time
|
logLine.time = split[1] // time
|
||||||
logLine.pid = split[2] // process id
|
logLine.pid = split[2] // process id
|
||||||
|
|||||||
+6
-6
@@ -112,7 +112,7 @@ parser code {:
|
|||||||
* patterns are expanded as "*[namespace-uri() = 'uri']" and
|
* patterns are expanded as "*[namespace-uri() = 'uri']" and
|
||||||
* "@*[namespace-uri() = 'uri']", respectively. This expansion considerably
|
* "@*[namespace-uri() = 'uri']", respectively. This expansion considerably
|
||||||
* simplifies the grouping of patterns in the Mode class. For this
|
* simplifies the grouping of patterns in the Mode class. For this
|
||||||
* expansion to be correct, the priority of the pattern/template must be
|
* expansion to be correct, the level of the pattern/template must be
|
||||||
* set to -0.25 (when no other predicates are present).
|
* set to -0.25 (when no other predicates are present).
|
||||||
*/
|
*/
|
||||||
public StepPattern createStepPattern(int axis, Object test, Vector predicates) {
|
public StepPattern createStepPattern(int axis, Object test, Vector predicates) {
|
||||||
@@ -131,7 +131,7 @@ parser code {:
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QName name = (QName)test;
|
QName name = (QName)test;
|
||||||
boolean setPriority = false;
|
boolean setLevel = false;
|
||||||
|
|
||||||
if (axis == Axis.NAMESPACE) {
|
if (axis == Axis.NAMESPACE) {
|
||||||
nodeType = (name.toString().equals("*")) ? -1
|
nodeType = (name.toString().equals("*")) ? -1
|
||||||
@@ -150,7 +150,7 @@ parser code {:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Priority is set by hand if no other predicates exist
|
// Priority is set by hand if no other predicates exist
|
||||||
setPriority = (predicates.size() == 0);
|
setLevel = (predicates.size() == 0);
|
||||||
|
|
||||||
predicates.add(
|
predicates.add(
|
||||||
new Predicate(
|
new Predicate(
|
||||||
@@ -174,9 +174,9 @@ parser code {:
|
|||||||
|
|
||||||
final StepPattern result = new StepPattern(axis, nodeType, predicates);
|
final StepPattern result = new StepPattern(axis, nodeType, predicates);
|
||||||
|
|
||||||
// Set priority for case prefix:* and prefix:@* (no predicates)
|
// Set level for case prefix:* and prefix:@* (no predicates)
|
||||||
if (setPriority) {
|
if (setLevel) {
|
||||||
result.setPriority(-0.25);
|
result.setLevel(-0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+3
-4
@@ -19,14 +19,13 @@ package com.itsaky.androidide.tooling.impl;
|
|||||||
|
|
||||||
import static com.itsaky.androidide.utils.ILogger.newInstance;
|
import static com.itsaky.androidide.utils.ILogger.newInstance;
|
||||||
|
|
||||||
import com.itsaky.androidide.models.LogLine;
|
|
||||||
import com.itsaky.androidide.tooling.api.IToolingApiClient;
|
import com.itsaky.androidide.tooling.api.IToolingApiClient;
|
||||||
import com.itsaky.androidide.tooling.api.messages.LogMessageParams;
|
import com.itsaky.androidide.tooling.api.messages.LogMessageParams;
|
||||||
import com.itsaky.androidide.tooling.api.util.ToolingApiLauncher;
|
import com.itsaky.androidide.tooling.api.util.ToolingApiLauncher;
|
||||||
import com.itsaky.androidide.tooling.impl.internal.ProjectImpl;
|
import com.itsaky.androidide.tooling.impl.internal.ProjectImpl;
|
||||||
import com.itsaky.androidide.tooling.impl.progress.ForwardingProgressListener;
|
import com.itsaky.androidide.tooling.impl.progress.ForwardingProgressListener;
|
||||||
import com.itsaky.androidide.utils.ILogger;
|
import com.itsaky.androidide.utils.ILogger;
|
||||||
import com.itsaky.androidide.utils.ILogger.Priority;
|
import com.itsaky.androidide.utils.ILogger.Level;
|
||||||
import com.itsaky.androidide.utils.JvmLogger;
|
import com.itsaky.androidide.utils.JvmLogger;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -125,9 +124,9 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void onLog(Priority priority, String tag, String message) {
|
private static void onLog(Level level, String tag, String message) {
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
client.logMessage(new LogMessageParams(priority.priorityChar, tag, message));
|
client.logMessage(new LogMessageParams(level.levelChar, tag, message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-8
@@ -44,16 +44,9 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.JUnit4
|
import org.junit.runners.JUnit4
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.nio.file.attribute.PosixFilePermission
|
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import kotlin.io.path.ExperimentalPathApi
|
|
||||||
import kotlin.io.path.createDirectories
|
|
||||||
import kotlin.io.path.createFile
|
import kotlin.io.path.createFile
|
||||||
import kotlin.io.path.deleteIfExists
|
import kotlin.io.path.deleteIfExists
|
||||||
import kotlin.io.path.deleteRecursively
|
|
||||||
import kotlin.io.path.exists
|
|
||||||
import kotlin.io.path.setPosixFilePermissions
|
|
||||||
import kotlin.io.path.writeText
|
|
||||||
|
|
||||||
/** @author Akash Yadav */
|
/** @author Akash Yadav */
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
@@ -363,7 +356,7 @@ class MultiModuleAndroidProjectTest {
|
|||||||
|
|
||||||
private val string = StringBuilder()
|
private val string = StringBuilder()
|
||||||
|
|
||||||
override fun doLog(priority: Priority?, message: String?) {
|
override fun doLog(level: Level?, message: String?) {
|
||||||
string.append("${message?.trim()}${System.lineSeparator()}")
|
string.append("${message?.trim()}${System.lineSeparator()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,5 +31,5 @@ data class LogMessageParams(val level: Char, val tag: String, val message: Strin
|
|||||||
* Creates a new [LogLine] instance from this [LogMessageParams].
|
* Creates a new [LogLine] instance from this [LogMessageParams].
|
||||||
*/
|
*/
|
||||||
fun LogMessageParams.toLogLine(): LogLine {
|
fun LogMessageParams.toLogLine(): LogLine {
|
||||||
return LogLine.obtain(ILogger.Priority.forChar(level), tag, message)
|
return LogLine.obtain(ILogger.Level.forChar(level), tag, message)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -17,19 +17,19 @@
|
|||||||
package com.itsaky.androidide.lsp.api.util
|
package com.itsaky.androidide.lsp.api.util
|
||||||
|
|
||||||
import com.itsaky.androidide.utils.ILogger
|
import com.itsaky.androidide.utils.ILogger
|
||||||
import com.itsaky.androidide.utils.ILogger.Priority
|
import com.itsaky.androidide.utils.ILogger.Level
|
||||||
|
|
||||||
/** @author Akash Yadav */
|
/** @author Akash Yadav */
|
||||||
class ReflectiveLogListener(private val receiver: Class<out Any>) : ILogger.LogListener {
|
class ReflectiveLogListener(private val receiver: Class<out Any>) : ILogger.LogListener {
|
||||||
override fun log(priority: Priority, tag: String, message: String) {
|
override fun log(level: Level, tag: String, message: String) {
|
||||||
val method =
|
val method =
|
||||||
receiver.getDeclaredMethod(
|
receiver.getDeclaredMethod(
|
||||||
"log",
|
"log",
|
||||||
Priority::class.java,
|
Level::class.java,
|
||||||
String::class.java,
|
String::class.java,
|
||||||
String::class.java
|
String::class.java
|
||||||
)
|
)
|
||||||
method.isAccessible = true
|
method.isAccessible = true
|
||||||
method.invoke(null, priority, tag, message)
|
method.invoke(null, level, tag, message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -153,7 +153,7 @@ class ToolingApiTestLauncher {
|
|||||||
|
|
||||||
override fun logMessage(params: LogMessageParams) {
|
override fun logMessage(params: LogMessageParams) {
|
||||||
val line = params.toLogLine()
|
val line = params.toLogLine()
|
||||||
log.log(line.priority, line.formattedTagAndMessage())
|
log.log(line.level, line.formattedTagAndMessage())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun logOutput(line: String) {
|
override fun logOutput(line: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user