TelemetryLogManager.java
net.minecraft.client.telemetry.TelemetryLogManager
信息
- 全限定名:net.minecraft.client.telemetry.TelemetryLogManager
- 类型:public class
- 包:net.minecraft.client.telemetry
- 源码路径:src/main/java/net/minecraft/client/telemetry/TelemetryLogManager.java
- 起始行号:L19
- 实现:AutoCloseable
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
RAW_EXTENSION- 类型:
String - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
EXPIRY_DAYS- 类型:
int - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
directory- 类型:
EventLogDirectory - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
sessionLog- 类型:
CompletableFuture<Optional<TelemetryEventLog>> - 修饰符:
private - 源码定位:
L24 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private TelemetryLogManager(EventLogDirectory directory) @ L26
- 构造器名:TelemetryLogManager
- 源码定位:L26
- 修饰符:private
参数:
- directory: EventLogDirectory
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static CompletableFuture<Optional<TelemetryLogManager>> open(Path root) @ L30
- 方法名:open
- 源码定位:L30
- 返回类型:CompletableFuture<Optional
> - 修饰符:public static
参数:
- root: Path
说明:
TODO
public CompletableFuture<Optional<TelemetryEventLogger>> openLogger() @ L43
- 方法名:openLogger
- 源码定位:L43
- 返回类型:CompletableFuture<Optional
> - 修饰符:public
参数:
- 无
说明:
TODO
public void close() @ L60
- 方法名:close
- 源码定位:L60
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class TelemetryLogManager implements AutoCloseable {
private static final Logger LOGGER = LogUtils.getLogger();
private static final String RAW_EXTENSION = ".json";
private static final int EXPIRY_DAYS = 7;
private final EventLogDirectory directory;
private @Nullable CompletableFuture<Optional<TelemetryEventLog>> sessionLog;
private TelemetryLogManager(EventLogDirectory directory) {
this.directory = directory;
}
public static CompletableFuture<Optional<TelemetryLogManager>> open(Path root) {
return CompletableFuture.supplyAsync(() -> {
try {
EventLogDirectory directory = EventLogDirectory.open(root, ".json");
directory.listFiles().prune(LocalDate.now(Clock.systemDefaultZone()), 7).compressAll();
return Optional.of(new TelemetryLogManager(directory));
} catch (Exception var2) {
LOGGER.error("Failed to create telemetry log manager", (Throwable)var2);
return Optional.empty();
}
}, Util.backgroundExecutor());
}
public CompletableFuture<Optional<TelemetryEventLogger>> openLogger() {
if (this.sessionLog == null) {
this.sessionLog = CompletableFuture.supplyAsync(() -> {
try {
EventLogDirectory.RawFile file = this.directory.createNewFile(LocalDate.now(Clock.systemDefaultZone()));
FileChannel channel = file.openChannel();
return Optional.of(new TelemetryEventLog(channel, Util.backgroundExecutor()));
} catch (IOException var3) {
LOGGER.error("Failed to open channel for telemetry event log", (Throwable)var3);
return Optional.empty();
}
}, Util.backgroundExecutor());
}
return this.sessionLog.thenApply(log -> log.map(TelemetryEventLog::logger));
}
@Override
public void close() {
if (this.sessionLog != null) {
this.sessionLog.thenAccept(log -> log.ifPresent(TelemetryEventLog::close));
}
}
}引用的其他类
-
- 引用位置:
字段/构造调用 - 关联成员:
TelemetryEventLog()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.backgroundExecutor()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
EventLogDirectory.open()
- 引用位置: