override fun extract()

in src/main/kotlin/com/github/mkartashev/hserr/miner/artifact/ExecutiveSummary.kt [233:295]


    override fun extract(log: HsErrLog): ExecutiveSummaryArtifact {
        val s = StringBuilder()

        val arch = log.getArtifact(ArchitectureArtifact::class)
        val os = log.getArtifact(OSArtifact::class)
        val header = log.getArtifact(HeaderArtifact::class)
        val signal = log.getArtifact(SignalInfoArtifact::class)
        val version = log.getArtifact(VersionArtifact::class)
        val uptime = log.getArtifact(UptimeArtifact::class)
        val thread = log.getArtifact(ThreadInfoArtifact::class)
        val system = log.getArtifact(SystemArtifact::class)
        val exceptions = log.getArtifact(InternalExceptionsArtifact::class)
        val threads = log.getArtifact(ThreadsArtifact::class)
        val heap = log.getArtifact(JavaHeapArtifact::class)
        val memory = log.getArtifact(ProcessMemoryArtifact::class)

        if (version != null) {
            s.append("JVM (${version.jvmVersionBuild})")
        } else {
            s.append("JVM (version unknown)")
        }

        s.append(" crashed")

        val osString = os?.name ?: ""
        val archString = arch?.family.toString()

        if (osString.isNotEmpty() || archString.isNotEmpty()) {
            s.append(" running on $osString")
            if (archString.isNotEmpty()) s.append(" (${archString})")
        }

        if (uptime != null) {
            if (uptime.uptime.toSeconds() <= 5) {
                s.append(" almost immediately after the start")
            } else {
                s.append(" after ${uptime.uptimeAsString} from the start")
            }
        }

        if (header != null || signal != null || thread != null) {
            describeCrash(s, header, thread, signal, exceptions)
        }

        if (threads != null) {
            describeThreads(s, threads, thread)
        }

        if (heap != null) {
            describeHeap(s, heap)
        }

        if (memory != null) {
            describeMemory(s, memory, system)
        }

        if (system != null) {
            describeSystem(s, system)
        }

        s.append(".")
        return ExecutiveSummaryArtifact(log, s.toString())
    }