diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-10-28 14:41:50 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-10-28 15:24:17 +0200 |
| commit | 8bf940eb7b59b5e5e326cfc06d51bdb54393f33b (patch) | |
| tree | 06c09e29737b219726772ef3d7deb3006ac06493 /opendc-compute/opendc-compute-simulator/src | |
| parent | dd5bbd55fc6e25efdfe93ec16bd37c5350e04c16 (diff) | |
perf(compute/sim): Use static logger field
This change updates the `Guest` class implementation to use a static
logger field instead of allocation a new logger for every guest.
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src')
| -rw-r--r-- | opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt index c12e6fad..ca947625 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt @@ -49,11 +49,6 @@ internal class Guest( val machine: SimVirtualMachine ) { /** - * The logger instance of this guest. - */ - private val logger = KotlinLogging.logger {} - - /** * The state of the [Guest]. * * [ServerState.PROVISIONING] is an invalid value for a guest, since it applies before the host is selected for @@ -68,12 +63,12 @@ internal class Guest( fun start() { when (state) { ServerState.TERMINATED, ServerState.ERROR -> { - logger.info { "User requested to start server ${server.uid}" } + LOGGER.info { "User requested to start server ${server.uid}" } doStart() } ServerState.RUNNING -> return ServerState.DELETED -> { - logger.warn { "User tried to start deleted server" } + LOGGER.warn { "User tried to start deleted server" } throw IllegalArgumentException("Server is deleted") } else -> assert(false) { "Invalid state transition" } @@ -239,4 +234,9 @@ internal class Guest( _downtime += duration } } + + private companion object { + @JvmStatic + private val LOGGER = KotlinLogging.logger {} + } } |
