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() {
|
||||
|
||||
private var logListener: ILogger.LogListener? =
|
||||
ILogger.LogListener { priority, tag, message ->
|
||||
ILogger.LogListener { level, tag, message ->
|
||||
if (message.contains("\n")) {
|
||||
val split = message.split("\n").toTypedArray()
|
||||
for (line in split) {
|
||||
logLine(priority, tag, line)
|
||||
logLine(level, tag, line)
|
||||
}
|
||||
} 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.models.LogLine
|
||||
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 io.github.rosemoe.sora.widget.style.CursorAnimator
|
||||
import java.util.concurrent.ArrayBlockingQueue
|
||||
@@ -195,8 +195,8 @@ abstract class LogViewFragment :
|
||||
|
||||
abstract fun isSimpleFormattingEnabled(): Boolean
|
||||
|
||||
protected open fun logLine(priority: Priority, tag: String, message: String) {
|
||||
val line = LogLine.obtain(priority, tag, message)
|
||||
protected open fun logLine(level: Level, tag: String, message: String) {
|
||||
val line = LogLine.obtain(level, tag, message)
|
||||
appendLog(line)
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
|
||||
|
||||
override fun logMessage(params: LogMessageParams) {
|
||||
val line = params.toLogLine()
|
||||
serverLogger.log(line.priority, line.formattedTagAndMessage())
|
||||
serverLogger.log(line.level, line.formattedTagAndMessage())
|
||||
}
|
||||
|
||||
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).
|
||||
- XML Code formatter. Thanks to @MrIkso (#182).
|
||||
- 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.
|
||||
- Syntax highlighting for Kotlin and C/C++ language. Thanks to @MrIkso (#196).
|
||||
- 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).
|
||||
- Do not show full error message when layout inflation fails (#274).
|
||||
- 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.
|
||||
- Use relative padding in TreeView to support RTL layouts.
|
||||
- Updated crash report. By @AndreyKozhev (#460).
|
||||
|
||||
@@ -35,5 +35,5 @@ _No notes_
|
||||
## Improvements
|
||||
|
||||
- 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.
|
||||
@@ -5,10 +5,10 @@
|
||||
(time) @err.time
|
||||
(pid) @err.pid
|
||||
(tid) @err.tid
|
||||
(priority) @err.priority
|
||||
(level) @err.level
|
||||
(tag) @err.tag
|
||||
(message) @err.msg
|
||||
(#match? @err.priority "E")
|
||||
(#match? @err.level "E")
|
||||
)
|
||||
|
||||
(log_line
|
||||
@@ -16,10 +16,10 @@
|
||||
(time) @warn.time
|
||||
(pid) @warn.pid
|
||||
(tid) @warn.tid
|
||||
(priority) @warn.priority
|
||||
(level) @warn.level
|
||||
(tag) @warn.tag
|
||||
(message) @warn.msg
|
||||
(#match? @warn.priority "W")
|
||||
(#match? @warn.level "W")
|
||||
)
|
||||
|
||||
(log_line
|
||||
@@ -27,10 +27,10 @@
|
||||
(time) @info.time
|
||||
(pid) @info.pid
|
||||
(tid) @info.tid
|
||||
(priority) @info.priority
|
||||
(level) @info.level
|
||||
(tag) @info.tag
|
||||
(message) @info.msg
|
||||
(#match? @info.priority "I")
|
||||
(#match? @info.level "I")
|
||||
)
|
||||
|
||||
(log_line
|
||||
@@ -38,10 +38,10 @@
|
||||
(time) @debug.time
|
||||
(pid) @debug.pid
|
||||
(tid) @debug.tid
|
||||
(priority) @debug.priority
|
||||
(level) @debug.level
|
||||
(tag) @debug.tag
|
||||
(message) @debug.msg
|
||||
(#match? @debug.priority "D")
|
||||
(#match? @debug.level "D")
|
||||
)
|
||||
|
||||
(log_line
|
||||
@@ -49,43 +49,43 @@
|
||||
(time) @verbose.time
|
||||
(pid) @verbose.pid
|
||||
(tid) @verbose.tid
|
||||
(priority) @verbose.priority
|
||||
(level) @verbose.level
|
||||
(tag) @verbose.tag
|
||||
(message) @verbose.msg
|
||||
(#match? @verbose.priority "V")
|
||||
(#match? @verbose.level "V")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @err.tag
|
||||
(priority) @err.priority
|
||||
(level) @err.level
|
||||
(message) @err.msg
|
||||
(#match? @err.priority "E")
|
||||
(#match? @err.level "E")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @warn.tag
|
||||
(priority) @warn.priority
|
||||
(level) @warn.level
|
||||
(message) @warn.msg
|
||||
(#match? @warn.priority "W")
|
||||
(#match? @warn.level "W")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @info.tag
|
||||
(priority) @info.priority
|
||||
(level) @info.level
|
||||
(message) @info.msg
|
||||
(#match? @info.priority "I")
|
||||
(#match? @info.level "I")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @debug.tag
|
||||
(priority) @debug.priority
|
||||
(level) @debug.level
|
||||
(message) @debug.msg
|
||||
(#match? @debug.priority "D")
|
||||
(#match? @debug.level "D")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @verbose.tag
|
||||
(priority) @verbose.priority
|
||||
(level) @verbose.level
|
||||
(message) @verbose.msg
|
||||
(#match? @verbose.priority "V")
|
||||
(#match? @verbose.level "V")
|
||||
)
|
||||
@@ -31,8 +31,8 @@ public class AndroidLogger extends ILogger {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLog(Priority priority, String message) {
|
||||
switch (priority) {
|
||||
protected void doLog(Level level, String message) {
|
||||
switch (level) {
|
||||
case ERROR:
|
||||
Log.e(TAG, message);
|
||||
break;
|
||||
|
||||
@@ -97,45 +97,45 @@ public abstract class ILogger {
|
||||
* @return This logger instance.
|
||||
*/
|
||||
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.
|
||||
* @return This logger instance.
|
||||
*/
|
||||
public ILogger log(Priority priority, Object... messages) {
|
||||
logAndNotify(priority, generateMessage(messages));
|
||||
public ILogger log(Level level, Object... messages) {
|
||||
logAndNotify(level, generateMessage(messages));
|
||||
return this;
|
||||
}
|
||||
|
||||
private void logAndNotify(Priority priority, String msg) {
|
||||
private void logAndNotify(Level level, String msg) {
|
||||
if (!isEnabled()) {
|
||||
// logger is disabled
|
||||
return;
|
||||
}
|
||||
|
||||
doLog(priority, msg);
|
||||
doLog(level, msg);
|
||||
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.
|
||||
*
|
||||
* @param priority The priority for this log message.
|
||||
* @param message The full generated message for this log. Might contain new lines.
|
||||
* @see ILogger.Priority#DEBUG
|
||||
* @see ILogger.Priority#ERROR
|
||||
* @see ILogger.Priority#WARNING
|
||||
* @see ILogger.Priority#VERBOSE
|
||||
* @see ILogger.Priority#INFO
|
||||
* @param level The log level for this message.
|
||||
* @param message The full generated message for this log. Might contain new lines.
|
||||
* @see Level#DEBUG
|
||||
* @see Level#ERROR
|
||||
* @see Level#WARNING
|
||||
* @see Level#VERBOSE
|
||||
* @see Level#INFO
|
||||
*/
|
||||
protected abstract void doLog(Priority priority, String message);
|
||||
protected abstract void doLog(Level level, String message);
|
||||
|
||||
protected String generateMessage(Object... messages) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -159,7 +159,7 @@ public abstract class ILogger {
|
||||
* @return This logger instance.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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'),
|
||||
WARNING('W'),
|
||||
@@ -244,21 +244,21 @@ public abstract class ILogger {
|
||||
INFO('I'),
|
||||
VERBOSE('V');
|
||||
|
||||
public final char priorityChar;
|
||||
public final char levelChar;
|
||||
|
||||
Priority(char priorityChar) {
|
||||
this.priorityChar = priorityChar;
|
||||
Level(char levelChar) {
|
||||
this.levelChar = levelChar;
|
||||
}
|
||||
|
||||
public static Priority forChar(char c) {
|
||||
public static Level forChar(char c) {
|
||||
c = Character.toUpperCase(c);
|
||||
for (Priority value : values()) {
|
||||
if (value.priorityChar == c) {
|
||||
for (Level value : values()) {
|
||||
if (value.levelChar == c) {
|
||||
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 {
|
||||
|
||||
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
|
||||
protected void doLog(Priority priority, String message) {
|
||||
protected void doLog(Level level, String message) {
|
||||
if (interceptor != null) {
|
||||
interceptor.onLog(priority, TAG, message);
|
||||
interceptor.onLog(level, TAG, message);
|
||||
} else {
|
||||
System.err.printf(
|
||||
"%-25s %-2s %s%n",
|
||||
trimTagIfNeeded(TAG, 25),
|
||||
priority.priorityChar,
|
||||
level.levelChar,
|
||||
message
|
||||
);
|
||||
}
|
||||
@@ -48,6 +48,6 @@ public class JvmLogger extends ILogger {
|
||||
|
||||
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
|
||||
clips from a
|
||||
{@link android.view.ViewAnimationUtils#createCircularReveal(View, int, int, float,
|
||||
float)} circular reveal animation take priority over Outline clipping, and child
|
||||
Outline clipping takes priority over Outline clipping done by a parent.
|
||||
float)} circular reveal animation take level over Outline clipping, and child
|
||||
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
|
||||
{@link android.graphics.Outline#canClip()}. -->
|
||||
<attr
|
||||
@@ -10650,8 +10650,8 @@
|
||||
name="bottom_to_top"
|
||||
value="0x2" />
|
||||
</attr>
|
||||
<!-- Priority of the rows and columns. When the priority is none,
|
||||
both rows and columns have the same priority. When the priority is
|
||||
<!-- Priority of the rows and columns. When the level is none,
|
||||
both rows and columns have the same level. When the level is
|
||||
column, the animations will be applied on the columns first. The same
|
||||
goes for rows. -->
|
||||
<attr name="directionPriority">
|
||||
|
||||
@@ -30,7 +30,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
var tid: String? = null
|
||||
var tag: String? = null
|
||||
var message: String? = null
|
||||
var priority: ILogger.Priority? = null
|
||||
var level: ILogger.Level? = null
|
||||
var formatted = false
|
||||
|
||||
// For JSONRpc and Recyclable
|
||||
@@ -40,7 +40,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
|
||||
fun toSimpleString(): String {
|
||||
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!!
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
time = null
|
||||
date = null
|
||||
unformatted = null
|
||||
priority = ILogger.Priority.DEBUG
|
||||
level = ILogger.Level.DEBUG
|
||||
formatted = false
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
override fun toString(): String {
|
||||
return if (formatted) String.format(
|
||||
"%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!!
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
if (tid != other.tid) return false
|
||||
if (tag != other.tag) 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
|
||||
|
||||
return true
|
||||
@@ -98,7 +98,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
result = 31 * result + (tid?.hashCode() ?: 0)
|
||||
result = 31 * result + (tag?.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()
|
||||
return result
|
||||
}
|
||||
@@ -114,10 +114,10 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun obtain(priority: ILogger.Priority?, tag: String?, message: String?,
|
||||
fun obtain(level: ILogger.Level?, tag: String?, message: String?,
|
||||
formatted: Boolean = true): LogLine {
|
||||
val logLine = logLinePool.obtain()
|
||||
logLine.priority = priority
|
||||
logLine.level = level
|
||||
logLine.tag = tag
|
||||
logLine.message = message
|
||||
logLine.formatted = formatted
|
||||
@@ -132,7 +132,7 @@ class LogLine private constructor() : DefaultRecyclable() {
|
||||
val logLine = logLinePool.obtain()
|
||||
try {
|
||||
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.time = split[1] // time
|
||||
logLine.pid = split[2] // process id
|
||||
|
||||
+6
-6
@@ -112,7 +112,7 @@ parser code {:
|
||||
* patterns are expanded as "*[namespace-uri() = 'uri']" and
|
||||
* "@*[namespace-uri() = 'uri']", respectively. This expansion considerably
|
||||
* 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).
|
||||
*/
|
||||
public StepPattern createStepPattern(int axis, Object test, Vector predicates) {
|
||||
@@ -131,7 +131,7 @@ parser code {:
|
||||
}
|
||||
else {
|
||||
QName name = (QName)test;
|
||||
boolean setPriority = false;
|
||||
boolean setLevel = false;
|
||||
|
||||
if (axis == Axis.NAMESPACE) {
|
||||
nodeType = (name.toString().equals("*")) ? -1
|
||||
@@ -150,7 +150,7 @@ parser code {:
|
||||
}
|
||||
|
||||
// Priority is set by hand if no other predicates exist
|
||||
setPriority = (predicates.size() == 0);
|
||||
setLevel = (predicates.size() == 0);
|
||||
|
||||
predicates.add(
|
||||
new Predicate(
|
||||
@@ -174,9 +174,9 @@ parser code {:
|
||||
|
||||
final StepPattern result = new StepPattern(axis, nodeType, predicates);
|
||||
|
||||
// Set priority for case prefix:* and prefix:@* (no predicates)
|
||||
if (setPriority) {
|
||||
result.setPriority(-0.25);
|
||||
// Set level for case prefix:* and prefix:@* (no predicates)
|
||||
if (setLevel) {
|
||||
result.setLevel(-0.25);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
+3
-4
@@ -19,14 +19,13 @@ package com.itsaky.androidide.tooling.impl;
|
||||
|
||||
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.messages.LogMessageParams;
|
||||
import com.itsaky.androidide.tooling.api.util.ToolingApiLauncher;
|
||||
import com.itsaky.androidide.tooling.impl.internal.ProjectImpl;
|
||||
import com.itsaky.androidide.tooling.impl.progress.ForwardingProgressListener;
|
||||
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 java.io.ByteArrayInputStream;
|
||||
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) {
|
||||
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.runners.JUnit4
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.attribute.PosixFilePermission
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import kotlin.io.path.ExperimentalPathApi
|
||||
import kotlin.io.path.createDirectories
|
||||
import kotlin.io.path.createFile
|
||||
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 */
|
||||
@RunWith(JUnit4::class)
|
||||
@@ -363,7 +356,7 @@ class MultiModuleAndroidProjectTest {
|
||||
|
||||
private val string = StringBuilder()
|
||||
|
||||
override fun doLog(priority: Priority?, message: String?) {
|
||||
override fun doLog(level: Level?, message: String?) {
|
||||
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].
|
||||
*/
|
||||
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
|
||||
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import com.itsaky.androidide.utils.ILogger.Priority
|
||||
import com.itsaky.androidide.utils.ILogger.Level
|
||||
|
||||
/** @author Akash Yadav */
|
||||
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 =
|
||||
receiver.getDeclaredMethod(
|
||||
"log",
|
||||
Priority::class.java,
|
||||
Level::class.java,
|
||||
String::class.java,
|
||||
String::class.java
|
||||
)
|
||||
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) {
|
||||
val line = params.toLogLine()
|
||||
log.log(line.priority, line.formattedTagAndMessage())
|
||||
log.log(line.level, line.formattedTagAndMessage())
|
||||
}
|
||||
|
||||
override fun logOutput(line: String) {
|
||||
|
||||
Reference in New Issue
Block a user