-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add java option -Dauthlibinjector.logFile
to customize the path of log file
#206
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,12 @@ gradle | |
开启此选项后, 日志仅会输出到控制台. | ||
|
||
需要注意的是, authlib-injector 的日志是不会输出到 Minecraft 服务端/客户端的日志文件中的. | ||
|
||
每次启动时, 日志文件都会被清空. 如果有多个进程使用同一个日志文件, 则只有最早启动的会成功打开日志文件. | ||
|
||
-Dauthlibinjector.logFile | ||
指定日志文件输出位置. | ||
可以填写绝对路径,也可以填写相对路径。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 标点请用英文半角。此外,请修改对应的英文readme。 |
||
在 -Dauthlibinjector.noLogFile 选项开启后,本选项将会失效。 | ||
|
||
-Dauthlibinjector.mojangNamespace={default|enabled|disabled} | ||
设置是否启用 Mojang 命名空间 (@mojang 后缀). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,7 @@ | |
import static java.nio.file.StandardOpenOption.WRITE; | ||
import static moe.yushi.authlibinjector.util.Logging.Level.INFO; | ||
import static moe.yushi.authlibinjector.util.Logging.Level.WARNING; | ||
import java.io.IOException; | ||
import java.io.PrintStream; | ||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.io.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不要使用通配符导入 |
||
import java.nio.channels.FileChannel; | ||
import java.nio.charset.Charset; | ||
import java.nio.file.Path; | ||
|
@@ -45,8 +42,15 @@ private static FileChannel openLogFile() { | |
log(INFO, "Logging to file is disabled"); | ||
return null; | ||
} | ||
|
||
Path logfilePath = Paths.get("authlib-injector.log").toAbsolutePath(); | ||
|
||
String logFileProperty = System.getProperty("authlibinjector.logFile"); | ||
Path logfilePath; | ||
if (logFileProperty == null) { | ||
logfilePath = Paths.get("authlib-injector.log").toAbsolutePath(); | ||
} else { | ||
logfilePath = new File(logFileProperty).toPath().toAbsolutePath(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不要使用 |
||
} | ||
|
||
try { | ||
FileChannel channel = FileChannel.open(logfilePath, CREATE, WRITE); | ||
if (channel.tryLock() == null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要编辑无关行。