All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avito.android.runner.devices.internal.EmulatorsLogsReporterImpl.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

There is a newer version: 2024.32
Show newest version
package com.avito.android.runner.devices.internal

import com.avito.k8s.model.KubePod
import com.avito.runner.service.worker.device.Serial
import java.io.File

internal class EmulatorsLogsReporterImpl(
    private val outputFolder: File,
    private val logcatDir: File,
    private val logcatTags: Collection
) : EmulatorsLogsReporter {

    override fun reportEmulatorLogs(pod: KubePod, emulatorName: Serial, log: String) {
        val logFile = getLogFile(emulatorName.value)
        logFile.parentFile?.mkdirs()
        logFile.appendText("--- Logs of emulator: $pod ---\n")
        logFile.appendText("$log\n")
    }

    override fun redirectLogcat(emulatorName: Serial, device: Device) {
        val logcatFile = getFile(
            dir = logcatDir,
            emulatorName = emulatorName.value
        )

        device.redirectLogcatToFile(
            file = logcatFile,
            tags = logcatTags
        )
    }

    override fun getLogFile(podIp: String): File {
        return File(File(outputFolder, DEVICES_LOGS), "$podIp.txt")
    }

    private fun getFile(
        dir: File,
        emulatorName: String
    ) = File(dir, "$emulatorName.txt").apply { parentFile?.mkdirs() }
}

private const val DEVICES_LOGS = "devices"




© 2015 - 2024 Weber Informatics LLC | Privacy Policy