From f16df4e5f03116876958a8c80258b8ff9634d28d Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 6 Oct 2023 16:36:21 +0200 Subject: [PATCH 1/5] deps: Upgrade the Log4j Kotlin API to version 1.3.0 See [1]. [1]: https://github.com/apache/logging-log4j-kotlin/releases/tag/rel%2F1.3.0 Signed-off-by: Sebastian Schuberth --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a20454c135255..c6c8bec415572 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -38,7 +38,7 @@ kotlinxHtml = "0.9.1" kotlinxSerialization = "1.6.0" ktor = "2.3.5" log4jApi = "2.20.0" -log4jApiKotlin = "1.2.0" +log4jApiKotlin = "1.3.0" logback = "1.4.11" maven = "3.9.4" mavenResolver = "1.9.16" From 8e475b1b956b0d4b4d34c54e1788aa239b28999b Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 6 Oct 2023 16:59:56 +0200 Subject: [PATCH 2/5] refactor: Avoid the logger to leak into the public API Use the new Log4j Kotlin API extension property to avoid the logger to leak into the public API via (public) companion objects. Also, find a better way to log from top-level functions by using `MethodHandles.lookup()` (introduced in JDK 7) to get the name of the Kotlin-internal class that is generated to hold top-level functions. SLF4J describes this as an idiomatic way to get a logger, see [1]. [1]: https://www.slf4j.org/faq.html#declaration_pattern Signed-off-by: Sebastian Schuberth --- advisor/src/main/kotlin/AdviceProvider.kt | 4 ---- advisor/src/main/kotlin/Advisor.kt | 4 ++-- .../src/main/kotlin/advisors/GitHubDefects.kt | 4 ++-- advisor/src/main/kotlin/advisors/NexusIq.kt | 4 +--- advisor/src/main/kotlin/advisors/OssIndex.kt | 4 +--- advisor/src/main/kotlin/advisors/Osv.kt | 8 +++----- .../src/main/kotlin/advisors/VulnerableCode.kt | 4 ---- analyzer/src/main/kotlin/Analyzer.kt | 10 ++++------ .../src/main/kotlin/AnalyzerResultBuilder.kt | 4 ---- analyzer/src/main/kotlin/PackageManager.kt | 4 ++-- analyzer/src/main/kotlin/managers/GoDep.kt | 4 +--- analyzer/src/main/kotlin/managers/GoMod.kt | 4 ++-- analyzer/src/main/kotlin/managers/Maven.kt | 3 --- analyzer/src/main/kotlin/managers/Sbt.kt | 10 +++++++--- analyzer/src/main/kotlin/managers/utils/Graph.kt | 4 +--- .../managers/utils/MavenDependencyHandler.kt | 4 +--- .../main/kotlin/managers/utils/MavenLogger.kt | 4 +--- .../main/kotlin/managers/utils/MavenSupport.kt | 12 ++++++------ .../utils/PackageManagerDependencyHandler.kt | 4 +--- cli/src/main/kotlin/OrtMain.kt | 4 +--- .../fossid-webapp/src/main/kotlin/Extensions.kt | 4 +++- .../src/main/kotlin/FossIdRestService.kt | 4 ++-- .../src/main/kotlin/GitHubService.kt | 6 +++--- .../src/test/kotlin/OrtImportOrderTest.kt | 2 +- downloader/src/main/kotlin/Downloader.kt | 4 +--- .../src/main/kotlin/VersionControlSystem.kt | 4 ++-- downloader/src/main/kotlin/vcs/Git.kt | 6 +++--- downloader/src/main/kotlin/vcs/GitRepo.kt | 4 +--- downloader/src/main/kotlin/vcs/GitWorkingTree.kt | 4 +--- downloader/src/main/kotlin/vcs/Mercurial.kt | 4 +--- downloader/src/main/kotlin/vcs/Subversion.kt | 4 +--- .../src/main/kotlin/vcs/SubversionWorkingTree.kt | 4 +++- evaluator/src/main/kotlin/Rule.kt | 4 +--- evaluator/src/main/kotlin/RuleSet.kt | 4 +--- evaluator/src/main/kotlin/SourceTreeResolver.kt | 4 ++-- .../src/main/kotlin/osadl/CompatibilityMatrix.kt | 4 ++-- .../commands/classifications/ImportCommand.kt | 4 ++-- model/src/main/kotlin/Issue.kt | 8 ++------ model/src/main/kotlin/OrtResult.kt | 10 +++++++--- model/src/main/kotlin/PackageCuration.kt | 4 +--- model/src/main/kotlin/ScannerRun.kt | 4 ++-- .../kotlin/config/FileArchiverConfiguration.kt | 4 ++-- .../config/FileListStorageConfiguration.kt | 4 +--- model/src/main/kotlin/config/OrtConfiguration.kt | 4 ++-- .../config/ProvenanceStorageConfiguration.kt | 4 +--- .../main/kotlin/utils/ConfigurationResolver.kt | 4 ++-- model/src/main/kotlin/utils/DatabaseUtils.kt | 4 ++-- .../main/kotlin/utils/DependencyGraphBuilder.kt | 4 +--- model/src/main/kotlin/utils/FileArchiver.kt | 4 ++-- .../kotlin/utils/FileProvenanceFileStorage.kt | 4 +--- .../utils/PostgresProvenanceFileStorage.kt | 4 ---- notifier/src/main/kotlin/modules/JiraNotifier.kt | 4 +--- .../advisor/src/main/kotlin/AdvisorCommand.kt | 4 ---- .../analyzer/src/main/kotlin/AnalyzerCommand.kt | 4 +--- .../api/src/main/kotlin/utils/Extensions.kt | 9 ++++++--- .../src/main/kotlin/DownloaderCommand.kt | 4 +--- .../src/main/kotlin/EvaluatorCommand.kt | 4 +--- .../notifier/src/main/kotlin/NotifierCommand.kt | 4 ---- .../reporter/src/main/kotlin/ReporterCommand.kt | 4 +--- .../src/main/kotlin/RequirementsCommand.kt | 4 +--- .../scanner/src/main/kotlin/ScannerCommand.kt | 4 +--- .../src/main/kotlin/UploadCurationsCommand.kt | 4 +--- .../main/kotlin/UploadResultToPostgresCommand.kt | 4 ---- .../main/kotlin/UploadResultToSw360Command.kt | 4 +--- .../kotlin/DirPackageConfigurationProvider.kt | 4 +--- .../OrtConfigPackageConfigurationProvider.kt | 6 ++---- .../ClearlyDefinedPackageCurationProvider.kt | 4 +--- .../main/kotlin/FilePackageCurationProvider.kt | 4 +--- .../kotlin/OrtConfigPackageCurationProvider.kt | 6 ++---- .../bundler/src/main/kotlin/Bundler.kt | 4 ++-- .../cargo/src/main/kotlin/Cargo.kt | 4 +--- .../cocoapods/src/main/kotlin/CocoaPods.kt | 4 +--- .../composer/src/main/kotlin/Composer.kt | 4 +--- .../conan/src/main/kotlin/Conan.kt | 4 ++-- .../src/main/kotlin/GradleInspector.kt | 10 ++++------ .../gradle/src/main/kotlin/Gradle.kt | 4 ++-- .../src/main/kotlin/GradleDependencyHandler.kt | 3 --- .../package-managers/node/src/main/kotlin/Npm.kt | 4 ++-- .../node/src/main/kotlin/Yarn.kt | 4 +--- .../node/src/main/kotlin/Yarn2.kt | 4 ++-- .../node/src/main/kotlin/utils/NpmSupport.kt | 16 +++++----------- .../nuget/src/main/kotlin/NuGet.kt | 4 +--- .../package-managers/pub/src/main/kotlin/Pub.kt | 4 ++-- .../pub/src/main/kotlin/utils/PubCacheReader.kt | 4 +--- .../python/src/main/kotlin/Pip.kt | 4 ++-- .../python/src/main/kotlin/Pipenv.kt | 4 +--- .../python/src/main/kotlin/Poetry.kt | 4 +--- .../src/main/kotlin/utils/PythonInspector.kt | 4 +--- .../python/src/main/kotlin/utils/PythonUtils.kt | 8 +++++++- .../spdx/src/main/kotlin/SpdxDocumentFile.kt | 6 ++---- .../src/main/kotlin/utils/SpdxDocumentCache.kt | 4 +--- .../main/kotlin/utils/SpdxResolvedDocument.kt | 6 +++--- .../spm/src/main/kotlin/SpmModel.kt | 10 +++++++--- .../stack/src/main/kotlin/Stack.kt | 4 +--- .../unmanaged/src/main/kotlin/Unmanaged.kt | 4 +--- .../fossid/src/main/kotlin/FossIdReporter.kt | 4 ++-- .../src/main/kotlin/FossIdSnippetReporter.kt | 4 +--- .../main/kotlin/FreemarkerTemplateProcessor.kt | 4 ++-- .../src/main/kotlin/GitLabLicenseModelMapper.kt | 6 +++--- .../opossum/src/main/kotlin/OpossumReporter.kt | 6 ++---- .../src/main/kotlin/SpdxDocumentModelMapper.kt | 4 +--- .../spdx/src/main/kotlin/SpdxDocumentReporter.kt | 4 ++-- .../askalono/src/main/kotlin/Askalono.kt | 4 +--- .../boyterlc/src/main/kotlin/BoyterLc.kt | 4 ++-- .../scanners/fossid/src/main/kotlin/FossId.kt | 4 ++-- .../fossid/src/main/kotlin/FossIdConfig.kt | 4 ++-- .../src/main/kotlin/FossIdNamingProvider.kt | 4 ++-- .../fossid/src/main/kotlin/FossIdScanResults.kt | 8 +++++++- .../fossid/src/main/kotlin/FossIdUrlProvider.kt | 4 ++-- plugins/scanners/fossid/src/main/kotlin/Utils.kt | 9 ++++++++- .../licensee/src/main/kotlin/Licensee.kt | 4 ++-- .../scancode/src/main/kotlin/ScanCode.kt | 4 ++-- .../scanners/scanoss/src/main/kotlin/ScanOss.kt | 4 +--- .../main/kotlin/CommandLinePathScannerWrapper.kt | 4 ---- scanner/src/main/kotlin/ScanResultsStorage.kt | 4 ++-- scanner/src/main/kotlin/Scanner.kt | 4 +--- .../FileBasedNestedProvenanceStorage.kt | 4 +--- .../FileBasedPackageProvenanceStorage.kt | 4 +--- .../provenance/NestedProvenanceResolver.kt | 4 +--- .../provenance/PackageProvenanceResolver.kt | 4 +--- .../kotlin/storages/ClearlyDefinedStorage.kt | 4 +--- .../src/main/kotlin/storages/FileBasedStorage.kt | 4 +--- .../src/main/kotlin/storages/PostgresStorage.kt | 4 ++-- .../storages/ProvenanceBasedFileStorage.kt | 4 +--- .../storages/ProvenanceBasedPostgresStorage.kt | 4 +--- scanner/src/main/kotlin/storages/Sw360Storage.kt | 4 ++-- utils/common/src/main/kotlin/ArchiveUtils.kt | 14 ++++++-------- utils/common/src/main/kotlin/CommandLineTool.kt | 4 ++-- utils/common/src/main/kotlin/DirectoryStash.kt | 4 +--- utils/common/src/main/kotlin/DiskCache.kt | 4 ++-- .../src/main/kotlin/EnvironmentVariableFilter.kt | 4 ++-- utils/common/src/main/kotlin/ProcessCapture.kt | 4 ++-- .../kotlin/storage/HttpFileStorageFunTest.kt | 4 +--- .../src/main/kotlin/DeclaredLicenseProcessor.kt | 4 ++-- utils/ort/src/main/kotlin/NetRcAuthenticator.kt | 10 ++++++---- utils/ort/src/main/kotlin/OkHttpClientHelper.kt | 12 ++++++++---- utils/ort/src/main/kotlin/OrtAuthenticator.kt | 4 ++-- utils/ort/src/main/kotlin/OrtProxySelector.kt | 4 ++-- .../src/main/kotlin/storage/HttpFileStorage.kt | 4 +--- .../src/main/kotlin/storage/LocalFileStorage.kt | 4 ---- utils/scripting/src/main/kotlin/ScriptRunner.kt | 4 +--- 141 files changed, 265 insertions(+), 411 deletions(-) diff --git a/advisor/src/main/kotlin/AdviceProvider.kt b/advisor/src/main/kotlin/AdviceProvider.kt index eaa004270aeaf..c0ffc14ef8ee1 100644 --- a/advisor/src/main/kotlin/AdviceProvider.kt +++ b/advisor/src/main/kotlin/AdviceProvider.kt @@ -19,8 +19,6 @@ package org.ossreviewtoolkit.advisor -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.model.AdvisorDetails import org.ossreviewtoolkit.model.AdvisorResult import org.ossreviewtoolkit.model.Package @@ -31,8 +29,6 @@ import org.ossreviewtoolkit.model.Package * or code analysis results. */ abstract class AdviceProvider(val providerName: String) { - private companion object : Logging - /** * For a given set of [Package]s, retrieve findings and return a map that associates packages with [AdvisorResult]s. */ diff --git a/advisor/src/main/kotlin/Advisor.kt b/advisor/src/main/kotlin/Advisor.kt index adad9cc976908..5a99ee3ed37e1 100644 --- a/advisor/src/main/kotlin/Advisor.kt +++ b/advisor/src/main/kotlin/Advisor.kt @@ -25,7 +25,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.withContext -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.AdvisorRecord import org.ossreviewtoolkit.model.AdvisorResult @@ -45,7 +45,7 @@ class Advisor( private val providerFactories: List, private val config: AdvisorConfiguration ) { - companion object : Logging { + companion object { /** * All [advice provider factories][AdviceProviderFactory] available in the classpath, associated by their names. */ diff --git a/advisor/src/main/kotlin/advisors/GitHubDefects.kt b/advisor/src/main/kotlin/advisors/GitHubDefects.kt index cc1536ab6e024..ee717324731db 100644 --- a/advisor/src/main/kotlin/advisors/GitHubDefects.kt +++ b/advisor/src/main/kotlin/advisors/GitHubDefects.kt @@ -31,7 +31,7 @@ import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.async import kotlinx.coroutines.withContext -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.advisor.AbstractAdviceProviderFactory import org.ossreviewtoolkit.advisor.AdviceProvider @@ -81,7 +81,7 @@ import org.ossreviewtoolkit.utils.ort.showStackTrace * suitable for production usage. */ class GitHubDefects(name: String, config: GitHubDefectsConfiguration) : AdviceProvider(name) { - companion object : Logging { + companion object { /** * The default number of parallel requests executed by this advisor implementation. This value is used if the * corresponding property in the configuration is unspecified. It is chosen rather arbitrarily. diff --git a/advisor/src/main/kotlin/advisors/NexusIq.kt b/advisor/src/main/kotlin/advisors/NexusIq.kt index b7768f171e191..cf680dd21ac6a 100644 --- a/advisor/src/main/kotlin/advisors/NexusIq.kt +++ b/advisor/src/main/kotlin/advisors/NexusIq.kt @@ -23,7 +23,7 @@ import java.net.URI import java.time.Duration import java.time.Instant -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.advisor.AbstractAdviceProviderFactory import org.ossreviewtoolkit.advisor.AdviceProvider @@ -65,8 +65,6 @@ private val READ_TIMEOUT = Duration.ofSeconds(60) * A wrapper for [Nexus IQ Server](https://help.sonatype.com/iqserver) security vulnerability data. */ class NexusIq(name: String, private val config: NexusIqConfiguration) : AdviceProvider(name) { - private companion object : Logging - class Factory : AbstractAdviceProviderFactory("NexusIQ") { override fun create(config: AdvisorConfiguration) = NexusIq(type, config.forProvider { nexusIq }) } diff --git a/advisor/src/main/kotlin/advisors/OssIndex.kt b/advisor/src/main/kotlin/advisors/OssIndex.kt index 7ca1ca7605f0c..5ea37a11c3293 100644 --- a/advisor/src/main/kotlin/advisors/OssIndex.kt +++ b/advisor/src/main/kotlin/advisors/OssIndex.kt @@ -22,7 +22,7 @@ package org.ossreviewtoolkit.advisor.advisors import java.net.URI import java.time.Instant -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.advisor.AbstractAdviceProviderFactory import org.ossreviewtoolkit.advisor.AdviceProvider @@ -53,8 +53,6 @@ private const val BULK_REQUEST_SIZE = 128 * A wrapper for Sonatype's [OSS Index](https://ossindex.sonatype.org/) security vulnerability data. */ class OssIndex(name: String, config: OssIndexConfiguration) : AdviceProvider(name) { - private companion object : Logging - class Factory : AbstractAdviceProviderFactory("OssIndex") { override fun create(config: AdvisorConfiguration) = OssIndex(type, config.forProvider { ossIndex ?: OssIndexConfiguration() }) diff --git a/advisor/src/main/kotlin/advisors/Osv.kt b/advisor/src/main/kotlin/advisors/Osv.kt index 158cb639ad47f..684d47fcde739 100644 --- a/advisor/src/main/kotlin/advisors/Osv.kt +++ b/advisor/src/main/kotlin/advisors/Osv.kt @@ -24,7 +24,7 @@ import java.time.Instant import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.contentOrNull -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.advisor.AbstractAdviceProviderFactory import org.ossreviewtoolkit.advisor.AdviceProvider @@ -53,8 +53,6 @@ import us.springett.cvss.Cvss * An advice provider that obtains vulnerability information from Open Source Vulnerabilities (https://osv.dev/). */ class Osv(name: String, config: OsvConfiguration) : AdviceProvider(name) { - internal companion object : Logging - class Factory : AbstractAdviceProviderFactory("OSV") { override fun create(config: AdvisorConfiguration) = // OSV does not require any dedicated configuration to be present. @@ -184,7 +182,7 @@ private fun Vulnerability.toOrtVulnerability(): org.ossreviewtoolkit.model.Vulne // Work around for https://github.com/stevespringett/cvss-calculator/issues/56. it.score.substringBefore("/") to "${cvss.calculateScore().baseScore}" } ?: run { - Osv.logger.debug { "Could not parse CVSS vector '${it.score}'." } + logger.debug { "Could not parse CVSS vector '${it.score}'." } null to it.score } } ?: (null to null) @@ -202,7 +200,7 @@ private fun Vulnerability.toOrtVulnerability(): org.ossreviewtoolkit.model.Vulne val url = reference.url.trim().let { if (it.startsWith("://")) "https$it" else it } url.toUri().onFailure { - Osv.logger.debug { "Could not parse reference URL for vulnerability '$id': ${it.message}." } + logger.debug { "Could not parse reference URL for vulnerability '$id': ${it.message}." } }.map { VulnerabilityReference( url = it, diff --git a/advisor/src/main/kotlin/advisors/VulnerableCode.kt b/advisor/src/main/kotlin/advisors/VulnerableCode.kt index bfe9f8f43d6fa..03ecfe440a04d 100644 --- a/advisor/src/main/kotlin/advisors/VulnerableCode.kt +++ b/advisor/src/main/kotlin/advisors/VulnerableCode.kt @@ -22,8 +22,6 @@ package org.ossreviewtoolkit.advisor.advisors import java.net.URI import java.time.Instant -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.advisor.AbstractAdviceProviderFactory import org.ossreviewtoolkit.advisor.AdviceProvider import org.ossreviewtoolkit.clients.vulnerablecode.VulnerableCodeService @@ -56,8 +54,6 @@ private const val BULK_REQUEST_SIZE = 100 * [VulnerableCode][https://github.com/nexB/vulnerablecode] instance. */ class VulnerableCode(name: String, config: VulnerableCodeConfiguration) : AdviceProvider(name) { - private companion object : Logging - class Factory : AbstractAdviceProviderFactory("VulnerableCode") { override fun create(config: AdvisorConfiguration) = VulnerableCode(type, config.forProvider { vulnerableCode }) } diff --git a/analyzer/src/main/kotlin/Analyzer.kt b/analyzer/src/main/kotlin/Analyzer.kt index 6e815caeeb531..56ce943359c15 100644 --- a/analyzer/src/main/kotlin/Analyzer.kt +++ b/analyzer/src/main/kotlin/Analyzer.kt @@ -34,7 +34,7 @@ import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.withContext -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.PackageManager.Companion.excludes import org.ossreviewtoolkit.downloader.VersionControlSystem @@ -57,8 +57,6 @@ import org.ossreviewtoolkit.utils.ort.Environment * The class to run the analysis. The signatures of public functions in this class define the library API. */ class Analyzer(private val config: AnalyzerConfiguration, private val labels: Map = emptyMap()) { - internal companion object : Logging - data class ManagedFileInfo( val absoluteProjectPath: File, val managedFiles: Map>, @@ -303,7 +301,7 @@ private class PackageManagerRunner( val remaining = mustRunAfter - finishedPackageManagers if (remaining.isNotEmpty()) { - Analyzer.logger.info { + logger.info { "${manager.managerName} is waiting for the following package managers to complete: " + remaining.joinToString(postfix = ".") } @@ -317,12 +315,12 @@ private class PackageManagerRunner( } private suspend fun run() { - Analyzer.logger.info { "Starting ${manager.managerName} analysis." } + logger.info { "Starting ${manager.managerName} analysis." } withContext(Dispatchers.IO) { val result = manager.resolveDependencies(definitionFiles, labels) - Analyzer.logger.info { "Finished ${manager.managerName} analysis." } + logger.info { "Finished ${manager.managerName} analysis." } onResult(result) } diff --git a/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt b/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt index d9e5c85bd75cd..7c34148af4a13 100644 --- a/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt +++ b/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt @@ -19,8 +19,6 @@ package org.ossreviewtoolkit.analyzer -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.analyzer.managers.utils.PackageManagerDependencyHandler import org.ossreviewtoolkit.model.AnalyzerResult import org.ossreviewtoolkit.model.DependencyGraph @@ -37,8 +35,6 @@ import org.ossreviewtoolkit.model.utils.convertToDependencyGraph import org.ossreviewtoolkit.utils.common.getDuplicates class AnalyzerResultBuilder { - private companion object : Logging - private val projects = mutableSetOf() private val packages = mutableSetOf() private val issues = mutableMapOf>() diff --git a/analyzer/src/main/kotlin/PackageManager.kt b/analyzer/src/main/kotlin/PackageManager.kt index 5607a0f620272..1094e13610add 100644 --- a/analyzer/src/main/kotlin/PackageManager.kt +++ b/analyzer/src/main/kotlin/PackageManager.kt @@ -30,7 +30,7 @@ import java.nio.file.attribute.BasicFileAttributes import kotlin.io.path.invariantSeparatorsPathString import kotlin.time.measureTime -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.apache.maven.project.ProjectBuildingException import org.ossreviewtoolkit.downloader.VcsHost @@ -69,7 +69,7 @@ abstract class PackageManager( val analyzerConfig: AnalyzerConfiguration, val repoConfig: RepositoryConfiguration ) { - companion object : Logging { + companion object { /** * All [package manager factories][PackageManagerFactory] available in the classpath, associated by their names. */ diff --git a/analyzer/src/main/kotlin/managers/GoDep.kt b/analyzer/src/main/kotlin/managers/GoDep.kt index 1575872c68bab..b6894f8d76eb0 100644 --- a/analyzer/src/main/kotlin/managers/GoDep.kt +++ b/analyzer/src/main/kotlin/managers/GoDep.kt @@ -28,7 +28,7 @@ import java.net.URI import kotlin.io.path.copyToRecursively import kotlin.io.path.createDirectories -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -84,8 +84,6 @@ class GoDep( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("GoDep") { override val globsForDefinitionFiles = listOf("Gopkg.toml", *GO_LEGACY_MANIFESTS.keys.toTypedArray()) diff --git a/analyzer/src/main/kotlin/managers/GoMod.kt b/analyzer/src/main/kotlin/managers/GoMod.kt index befe8806cd12a..df63c44c6da2c 100644 --- a/analyzer/src/main/kotlin/managers/GoMod.kt +++ b/analyzer/src/main/kotlin/managers/GoMod.kt @@ -27,7 +27,7 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeFromStream import kotlinx.serialization.json.decodeToSequence -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -68,7 +68,7 @@ class GoMod( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - companion object : Logging { + companion object { const val DEFAULT_GO_PROXY = "https://proxy.golang.org" val JSON = Json { ignoreUnknownKeys = true } diff --git a/analyzer/src/main/kotlin/managers/Maven.kt b/analyzer/src/main/kotlin/managers/Maven.kt index 1b324e37f353c..6c949636320c7 100644 --- a/analyzer/src/main/kotlin/managers/Maven.kt +++ b/analyzer/src/main/kotlin/managers/Maven.kt @@ -21,7 +21,6 @@ package org.ossreviewtoolkit.analyzer.managers import java.io.File -import org.apache.logging.log4j.kotlin.Logging import org.apache.maven.project.ProjectBuildingResult import org.eclipse.aether.artifact.Artifact @@ -56,8 +55,6 @@ class Maven( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig) { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("Maven") { override val globsForDefinitionFiles = listOf("pom.xml") diff --git a/analyzer/src/main/kotlin/managers/Sbt.kt b/analyzer/src/main/kotlin/managers/Sbt.kt index 4a323d5f7858b..5520e27a8b346 100644 --- a/analyzer/src/main/kotlin/managers/Sbt.kt +++ b/analyzer/src/main/kotlin/managers/Sbt.kt @@ -21,12 +21,14 @@ package org.ossreviewtoolkit.analyzer.managers import java.io.File import java.io.IOException +import java.lang.invoke.MethodHandles import java.nio.file.StandardCopyOption import java.util.Properties import kotlin.io.path.moveTo -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger +import org.apache.logging.log4j.kotlin.loggerOf import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -53,7 +55,7 @@ class Sbt( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - companion object : Logging { + companion object { // See https://github.com/sbt/sbt/blob/v1.5.1/launcher-package/integration-test/src/test/scala/RunnerTest.scala#L9. private const val SBT_VERSION_PATTERN = "\\d(\\.\\d+){2}(-\\w+)?" @@ -232,13 +234,15 @@ class Sbt( throw NotImplementedError() } +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + private fun moveGeneratedPom(pomFile: File): File { val targetDirParent = pomFile.absoluteFile.parentFile.searchUpwardsForSubdirectory("target") ?: return pomFile val targetFilename = pomFile.relativeTo(targetDirParent).invariantSeparatorsPath.replace('/', '-') val targetFile = targetDirParent.resolve(targetFilename) if (runCatching { pomFile.toPath().moveTo(targetFile.toPath(), StandardCopyOption.ATOMIC_MOVE) }.isFailure) { - Sbt.logger.error { "Moving '${pomFile.absolutePath}' to '${targetFile.absolutePath}' failed." } + logger.error { "Moving '${pomFile.absolutePath}' to '${targetFile.absolutePath}' failed." } return pomFile } diff --git a/analyzer/src/main/kotlin/managers/utils/Graph.kt b/analyzer/src/main/kotlin/managers/utils/Graph.kt index a147c0cc70d21..6f4a8d25237c9 100644 --- a/analyzer/src/main/kotlin/managers/utils/Graph.kt +++ b/analyzer/src/main/kotlin/managers/utils/Graph.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.analyzer.managers.utils import java.util.LinkedList -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.PackageLinkage @@ -32,8 +32,6 @@ import org.ossreviewtoolkit.model.PackageReference * map whose keys are package identifiers and whose values are the identifiers of packages these packages depend on. */ internal class Graph private constructor(private val nodeMap: MutableMap>) { - private companion object : Logging - constructor() : this(mutableMapOf()) /** diff --git a/analyzer/src/main/kotlin/managers/utils/MavenDependencyHandler.kt b/analyzer/src/main/kotlin/managers/utils/MavenDependencyHandler.kt index 198d7e67df8a7..76fcad61ab22d 100644 --- a/analyzer/src/main/kotlin/managers/utils/MavenDependencyHandler.kt +++ b/analyzer/src/main/kotlin/managers/utils/MavenDependencyHandler.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.analyzer.managers.utils -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.apache.maven.project.MavenProject import org.eclipse.aether.graph.DependencyNode @@ -55,8 +55,6 @@ class MavenDependencyHandler( */ private val sbtMode: Boolean ) : DependencyHandler { - private companion object : Logging - /** * A set of identifiers that are known to point to local projects. This is updated for packages that are resolved * to projects. diff --git a/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt b/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt index fe4cf4319d34d..94b2773317b0e 100644 --- a/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt +++ b/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt @@ -20,7 +20,7 @@ package org.ossreviewtoolkit.analyzer.managers.utils import org.apache.logging.log4j.Level -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.codehaus.plexus.logging.AbstractLogger import org.codehaus.plexus.logging.Logger @@ -45,8 +45,6 @@ private fun toPlexusLoggerLevel(level: Level) = * appropriate log levels. */ class MavenLogger(level: Level) : AbstractLogger(toPlexusLoggerLevel(level), "MavenLogger") { - private companion object : Logging - override fun getChildLogger(name: String?) = this override fun debug(message: String, throwable: Throwable?) = logger.debug(message, throwable) diff --git a/analyzer/src/main/kotlin/managers/utils/MavenSupport.kt b/analyzer/src/main/kotlin/managers/utils/MavenSupport.kt index 4883ccd94890d..6bb5bb0121bf8 100644 --- a/analyzer/src/main/kotlin/managers/utils/MavenSupport.kt +++ b/analyzer/src/main/kotlin/managers/utils/MavenSupport.kt @@ -24,7 +24,7 @@ import java.net.URI import kotlin.time.Duration.Companion.hours -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager import org.apache.maven.bridge.MavenRepositorySystem import org.apache.maven.execution.DefaultMavenExecutionRequest @@ -109,7 +109,7 @@ private val File?.safePath: String get() = this?.invariantSeparatorsPath ?: "" class MavenSupport(private val workspaceReader: WorkspaceReader) { - companion object : Logging { + companion object { private val PACKAGING_TYPES = setOf( // Core packaging types, see https://maven.apache.org/pom.html#packaging. "pom", "jar", "maven-plugin", "ejb", "war", "ear", "rar", @@ -137,7 +137,7 @@ class MavenSupport(private val workspaceReader: WorkspaceReader) { return DefaultPlexusContainer(configuration).apply { loggerManager = object : BaseLoggerManager() { - override fun createLogger(name: String) = MavenLogger(MavenSupport.logger.delegate.level) + override fun createLogger(name: String) = MavenLogger(logger.delegate.level) } } } @@ -584,13 +584,13 @@ class MavenSupport(private val workspaceReader: WorkspaceReader) { artifactDownload.isExistenceCheck = true artifactDownload.listener = object : AbstractTransferListener() { override fun transferFailed(event: TransferEvent?) { - MavenSupport.logger.debug { + logger.debug { "Transfer failed for repository with ID '${info.repository.id}': $event" } } override fun transferSucceeded(event: TransferEvent?) { - MavenSupport.logger.debug { "Transfer succeeded: $event" } + logger.debug { "Transfer succeeded: $event" } } } @@ -828,7 +828,7 @@ class MavenSupport(private val workspaceReader: WorkspaceReader) { * [Medium article](https://medium.com/p/d069d253fe23) */ private class HttpsMirrorSelector(private val originalMirrorSelector: MirrorSelector?) : MirrorSelector { - companion object : Logging { + companion object { private val DISABLED_HTTP_REPOSITORY_URLS = listOf( "http://jcenter.bintray.com", "http://repo.maven.apache.org", diff --git a/analyzer/src/main/kotlin/managers/utils/PackageManagerDependencyHandler.kt b/analyzer/src/main/kotlin/managers/utils/PackageManagerDependencyHandler.kt index 557cdf6fe5762..128ee3ebbced7 100644 --- a/analyzer/src/main/kotlin/managers/utils/PackageManagerDependencyHandler.kt +++ b/analyzer/src/main/kotlin/managers/utils/PackageManagerDependencyHandler.kt @@ -22,7 +22,7 @@ package org.ossreviewtoolkit.analyzer.managers.utils import kotlin.contracts.ExperimentalContracts import kotlin.contracts.contract -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.AnalyzerResult import org.ossreviewtoolkit.model.DependencyGraphNavigator @@ -113,8 +113,6 @@ private data class PackageManagerDependency( val scope: String, val linkage: PackageLinkage ) { - private companion object : Logging - fun findProjects(analyzerResult: AnalyzerResult): List = analyzerResult.projects.filter { it.definitionFilePath == definitionFile }.also { projects -> if (projects.isEmpty()) { diff --git a/cli/src/main/kotlin/OrtMain.kt b/cli/src/main/kotlin/OrtMain.kt index bed034d63bf70..ea2afba9c0366 100644 --- a/cli/src/main/kotlin/OrtMain.kt +++ b/cli/src/main/kotlin/OrtMain.kt @@ -44,7 +44,7 @@ import com.github.ajalt.mordant.table.grid import kotlin.system.exitProcess -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.config.LicenseFilePatterns import org.ossreviewtoolkit.model.config.OrtConfiguration @@ -91,8 +91,6 @@ class OrtMain : CliktCommand( epilog = "$REQUIRED_OPTION_MARKER denotes required options.", invokeWithoutSubcommand = true ) { - private companion object : Logging - private val configFile by option("--config", "-c", help = "The path to a configuration file.") .convert { it.expandTilde() } .file(mustExist = true, canBeFile = true, canBeDir = false, mustBeWritable = false, mustBeReadable = true) diff --git a/clients/fossid-webapp/src/main/kotlin/Extensions.kt b/clients/fossid-webapp/src/main/kotlin/Extensions.kt index 62355db61d00d..95f5624925ead 100644 --- a/clients/fossid-webapp/src/main/kotlin/Extensions.kt +++ b/clients/fossid-webapp/src/main/kotlin/Extensions.kt @@ -27,6 +27,8 @@ import java.util.Base64 import okio.buffer import okio.sink +import org.apache.logging.log4j.kotlin.logger + import org.ossreviewtoolkit.clients.fossid.model.identification.common.LicenseMatchType import org.ossreviewtoolkit.clients.fossid.model.report.ReportType import org.ossreviewtoolkit.clients.fossid.model.report.SelectionType @@ -424,7 +426,7 @@ suspend fun FossIdRestService.generateReport( contentDisposition?.split(';')?.firstNotNullOfOrNull { it.trim().withoutPrefix("filename=")?.removeSurrounding("\"") } ?: return Result.failure(IllegalStateException("Cannot determine name of the report")).also { - FossIdRestService.logger.error { + logger.error { "Cannot determine name of the report with raw headers '$contentDisposition'." } } diff --git a/clients/fossid-webapp/src/main/kotlin/FossIdRestService.kt b/clients/fossid-webapp/src/main/kotlin/FossIdRestService.kt index 739356b23ee50..4790c6add3775 100644 --- a/clients/fossid-webapp/src/main/kotlin/FossIdRestService.kt +++ b/clients/fossid-webapp/src/main/kotlin/FossIdRestService.kt @@ -41,7 +41,7 @@ import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.ResponseBody -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.fossid.model.Project import org.ossreviewtoolkit.clients.fossid.model.Scan @@ -67,7 +67,7 @@ import retrofit2.http.POST private const val READ_TIMEOUT_HEADER = "READ_TIMEOUT" interface FossIdRestService { - companion object : Logging { + companion object { /** * The mapper for JSON (de-)serialization used by this service. */ diff --git a/clients/github-graphql/src/main/kotlin/GitHubService.kt b/clients/github-graphql/src/main/kotlin/GitHubService.kt index aa6ad5f846a46..b74fd19a6862e 100644 --- a/clients/github-graphql/src/main/kotlin/GitHubService.kt +++ b/clients/github-graphql/src/main/kotlin/GitHubService.kt @@ -33,7 +33,7 @@ import java.net.URI import kotlin.time.measureTimedValue -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.github.issuesquery.Issue import org.ossreviewtoolkit.clients.github.releasesquery.Release @@ -62,7 +62,7 @@ class QueryException( class GitHubService private constructor( val client: GraphQLKtorClient ) { - companion object : Logging { + companion object { /** * The default endpoint URL for accessing the GitHub GraphQL API. */ @@ -136,7 +136,7 @@ private suspend fun GraphQLKtorClient.executeAndCheck( ): GraphQLClientResponse { val (result, duration) = measureTimedValue { execute(request) } - GitHubService.logger.debug { "Executed query '${request.operationName}' in $duration." } + logger.debug { "Executed query '${request.operationName}' in $duration." } result.errors?.let { errors -> throw QueryException("Result of query '${request.operationName}' contains errors.", errors) diff --git a/detekt-rules/src/test/kotlin/OrtImportOrderTest.kt b/detekt-rules/src/test/kotlin/OrtImportOrderTest.kt index 5c778957bc42e..ead8c578adc52 100644 --- a/detekt-rules/src/test/kotlin/OrtImportOrderTest.kt +++ b/detekt-rules/src/test/kotlin/OrtImportOrderTest.kt @@ -47,7 +47,7 @@ class OrtImportOrderTest : WordSpec({ import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.withContext - import org.apache.logging.log4j.kotlin.Logging + import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.PackageManager.Companion.excludes import org.ossreviewtoolkit.analyzer.managers.Unmanaged diff --git a/downloader/src/main/kotlin/Downloader.kt b/downloader/src/main/kotlin/Downloader.kt index 310e093b3cc34..bdb3cd6cfe49b 100644 --- a/downloader/src/main/kotlin/Downloader.kt +++ b/downloader/src/main/kotlin/Downloader.kt @@ -26,7 +26,7 @@ import java.net.URI import kotlin.time.TimeSource -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.ArtifactProvenance import org.ossreviewtoolkit.model.HashAlgorithm @@ -54,8 +54,6 @@ import org.ossreviewtoolkit.utils.ort.ping * The class to download source code. The signatures of public functions in this class define the library API. */ class Downloader(private val config: DownloaderConfiguration) { - private companion object : Logging - private fun verifyOutputDirectory(outputDirectory: File) { require(!outputDirectory.exists() || outputDirectory.list().isEmpty()) { "The output directory '$outputDirectory' must not contain any files yet." diff --git a/downloader/src/main/kotlin/VersionControlSystem.kt b/downloader/src/main/kotlin/VersionControlSystem.kt index a3811e67ff07d..3e9b996efc93c 100644 --- a/downloader/src/main/kotlin/VersionControlSystem.kt +++ b/downloader/src/main/kotlin/VersionControlSystem.kt @@ -23,7 +23,7 @@ import java.io.File import java.io.IOException import java.util.ServiceLoader -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Package import org.ossreviewtoolkit.model.VcsInfo @@ -45,7 +45,7 @@ abstract class VersionControlSystem( */ private val commandLineTool: CommandLineTool? = null ) { - companion object : Logging { + companion object { private val LOADER = ServiceLoader.load(VersionControlSystem::class.java) /** diff --git a/downloader/src/main/kotlin/vcs/Git.kt b/downloader/src/main/kotlin/vcs/Git.kt index 7953f8839123c..293ba64843f37 100644 --- a/downloader/src/main/kotlin/vcs/Git.kt +++ b/downloader/src/main/kotlin/vcs/Git.kt @@ -25,7 +25,7 @@ import java.net.Authenticator import java.net.InetSocketAddress import java.security.PublicKey -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.LsRemoteCommand @@ -66,7 +66,7 @@ private val REPOSITORY_URL_PREFIX_REPLACEMENTS = mapOf( ) class Git : VersionControlSystem(), CommandLineTool { - companion object : Logging { + companion object { init { // Make sure that JGit uses the exact same authentication information as ORT itself. This addresses // discrepancies in the way .netrc files are interpreted between JGit's and ORT's implementation. @@ -274,7 +274,7 @@ class Git : VersionControlSystem(), CommandLineTool { * [Authenticator]. An instance of this class is installed by [Git], making sure that JGit uses the exact same * authentication mechanism as ORT. */ -internal object AuthenticatorCredentialsProvider : CredentialsProvider(), Logging { +internal object AuthenticatorCredentialsProvider : CredentialsProvider() { override fun isInteractive(): Boolean = false override fun supports(vararg items: CredentialItem): Boolean = diff --git a/downloader/src/main/kotlin/vcs/GitRepo.kt b/downloader/src/main/kotlin/vcs/GitRepo.kt index e2fe0549e061e..3eb008eabcdc5 100644 --- a/downloader/src/main/kotlin/vcs/GitRepo.kt +++ b/downloader/src/main/kotlin/vcs/GitRepo.kt @@ -24,7 +24,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.eclipse.jgit.lib.SymbolicRef @@ -67,8 +67,6 @@ private data class Include( ) class GitRepo : VersionControlSystem(), CommandLineTool { - private companion object : Logging - override val type = VcsType.GIT_REPO override val priority = 50 override val latestRevisionNames = listOf("HEAD", "@") diff --git a/downloader/src/main/kotlin/vcs/GitWorkingTree.kt b/downloader/src/main/kotlin/vcs/GitWorkingTree.kt index 73cf75e513f48..cc62dfe569b15 100644 --- a/downloader/src/main/kotlin/vcs/GitWorkingTree.kt +++ b/downloader/src/main/kotlin/vcs/GitWorkingTree.kt @@ -22,7 +22,7 @@ package org.ossreviewtoolkit.downloader.vcs import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.eclipse.jgit.api.LsRemoteCommand import org.eclipse.jgit.lib.BranchConfig @@ -55,8 +55,6 @@ open class GitWorkingTree( vcsType: VcsType, private val repositoryUrlPrefixReplacements: Map = emptyMap() ) : WorkingTree(workingDir, vcsType) { - private companion object : Logging - fun useRepo(block: Repository.() -> T): T = findGitOrSubmoduleDir(workingDir).use(block) override fun isValid(): Boolean = useRepo { objectDatabase?.exists() == true } diff --git a/downloader/src/main/kotlin/vcs/Mercurial.kt b/downloader/src/main/kotlin/vcs/Mercurial.kt index e82a85faef6d5..e9ea098fadbdd 100644 --- a/downloader/src/main/kotlin/vcs/Mercurial.kt +++ b/downloader/src/main/kotlin/vcs/Mercurial.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.downloader.vcs import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.VersionControlSystem import org.ossreviewtoolkit.downloader.WorkingTree @@ -47,8 +47,6 @@ object MercurialCommand : CommandLineTool { } class Mercurial : VersionControlSystem(MercurialCommand) { - private companion object : Logging - override val type = VcsType.MERCURIAL override val priority = 20 override val latestRevisionNames = listOf("tip") diff --git a/downloader/src/main/kotlin/vcs/Subversion.kt b/downloader/src/main/kotlin/vcs/Subversion.kt index 6d6aabf984123..4e91820d14c08 100644 --- a/downloader/src/main/kotlin/vcs/Subversion.kt +++ b/downloader/src/main/kotlin/vcs/Subversion.kt @@ -24,7 +24,7 @@ import java.net.InetSocketAddress import java.net.URI import java.nio.file.Paths -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.DownloadException import org.ossreviewtoolkit.downloader.VersionControlSystem @@ -53,8 +53,6 @@ import org.tmatesoft.svn.core.wc.SVNRevision import org.tmatesoft.svn.util.Version class Subversion : VersionControlSystem() { - internal companion object : Logging - private val ortAuthManager = OrtSVNAuthenticationManager() private val clientManager = SVNClientManager.newInstance().apply { setAuthenticationManager(ortAuthManager) diff --git a/downloader/src/main/kotlin/vcs/SubversionWorkingTree.kt b/downloader/src/main/kotlin/vcs/SubversionWorkingTree.kt index b84e7160d2cc0..0ceea2908c0a1 100644 --- a/downloader/src/main/kotlin/vcs/SubversionWorkingTree.kt +++ b/downloader/src/main/kotlin/vcs/SubversionWorkingTree.kt @@ -21,6 +21,8 @@ package org.ossreviewtoolkit.downloader.vcs import java.io.File +import org.apache.logging.log4j.kotlin.logger + import org.ossreviewtoolkit.downloader.WorkingTree import org.ossreviewtoolkit.model.VcsType import org.ossreviewtoolkit.utils.ort.showStackTrace @@ -83,7 +85,7 @@ class SubversionWorkingTree( } catch (e: SVNException) { e.showStackTrace() - Subversion.logger.info { "Unable to list remote refs for $vcsType repository at $remoteUrl." } + logger.info { "Unable to list remote refs for $vcsType repository at $remoteUrl." } } return refs diff --git a/evaluator/src/main/kotlin/Rule.kt b/evaluator/src/main/kotlin/Rule.kt index 3ae18c22aa777..8d7499342d028 100644 --- a/evaluator/src/main/kotlin/Rule.kt +++ b/evaluator/src/main/kotlin/Rule.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.evaluator -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.Issue @@ -44,8 +44,6 @@ abstract class Rule( */ val name: String ) { - private companion object : Logging - private val ruleMatcherManager = RuleMatcherManager() /** diff --git a/evaluator/src/main/kotlin/RuleSet.kt b/evaluator/src/main/kotlin/RuleSet.kt index 00a01c18d0d75..d90f3f2991a5d 100644 --- a/evaluator/src/main/kotlin/RuleSet.kt +++ b/evaluator/src/main/kotlin/RuleSet.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.evaluator -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.DependencyNode import org.ossreviewtoolkit.model.OrtResult @@ -40,8 +40,6 @@ class RuleSet( val resolutionProvider: ResolutionProvider, val projectSourceResolver: SourceTreeResolver ) { - private companion object : Logging - /** * The set of all issues created by the rules of this [RuleSet]. */ diff --git a/evaluator/src/main/kotlin/SourceTreeResolver.kt b/evaluator/src/main/kotlin/SourceTreeResolver.kt index ed6e52904127e..e7c7709eac576 100644 --- a/evaluator/src/main/kotlin/SourceTreeResolver.kt +++ b/evaluator/src/main/kotlin/SourceTreeResolver.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.evaluator import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.Downloader import org.ossreviewtoolkit.model.Package @@ -31,7 +31,7 @@ import org.ossreviewtoolkit.model.config.DownloaderConfiguration import org.ossreviewtoolkit.utils.ort.createOrtTempDir class SourceTreeResolver private constructor(getRepositoryRoot: () -> File) { - companion object : Logging { + companion object { fun forRemoteRepository(vcsInfo: VcsInfo) = SourceTreeResolver { val downloadDir = createOrtTempDir() diff --git a/evaluator/src/main/kotlin/osadl/CompatibilityMatrix.kt b/evaluator/src/main/kotlin/osadl/CompatibilityMatrix.kt index 275edef31c217..da14877514793 100644 --- a/evaluator/src/main/kotlin/osadl/CompatibilityMatrix.kt +++ b/evaluator/src/main/kotlin/osadl/CompatibilityMatrix.kt @@ -26,13 +26,13 @@ import java.time.format.DateTimeFormatter import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeFromStream -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * An object that represents the OSADL compliance matrix. For details see * https://www.osadl.org/Access-to-raw-data.oss-compliance-raw-data-access.0.html. */ -object CompatibilityMatrix : Logging { +object CompatibilityMatrix { /** * A class to represent the information contained in a cell of the matrix, i.e. the result of a lookup. */ diff --git a/helper-cli/src/main/kotlin/commands/classifications/ImportCommand.kt b/helper-cli/src/main/kotlin/commands/classifications/ImportCommand.kt index 08240ed017bae..539b4d2fa1bd5 100644 --- a/helper-cli/src/main/kotlin/commands/classifications/ImportCommand.kt +++ b/helper-cli/src/main/kotlin/commands/classifications/ImportCommand.kt @@ -31,7 +31,7 @@ import com.github.ajalt.clikt.parameters.types.file import java.net.URI -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.jsonMapper import org.ossreviewtoolkit.model.licenses.LicenseCategorization @@ -81,7 +81,7 @@ private data class EclipseLicenses( val restricted: Map ) -private enum class LicenseClassificationProvider(val url: String) : Logging { +private enum class LicenseClassificationProvider(val url: String) { DOUBLE_OPEN("https://github.com/doubleopen-project/policy-configuration/raw/main/license-classifications.yml") { override fun getClassifications(): LicenseClassifications = yamlMapper.readValue(URI.create(url).toURL()) }, diff --git a/model/src/main/kotlin/Issue.kt b/model/src/main/kotlin/Issue.kt index 5667f3e94a77b..4e6cf8320c075 100644 --- a/model/src/main/kotlin/Issue.kt +++ b/model/src/main/kotlin/Issue.kt @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer import java.time.Instant -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.utils.common.normalizeLineBreaks @@ -70,11 +70,7 @@ class NormalizeLineBreaksSerializer : StdSerializer(String::class.java) /** * Create an [Issue] and log the message. The log level is aligned with the [severity]. */ -inline fun T.createAndLogIssue( - source: String, - message: String, - severity: Severity? = null -): Issue { +fun Any.createAndLogIssue(source: String, message: String, severity: Severity? = null): Issue { val issue = severity?.let { Issue(source = source, message = message, severity = it) } ?: Issue(source = source, message = message) logger.log(issue.severity.toLog4jLevel()) { message } diff --git a/model/src/main/kotlin/OrtResult.kt b/model/src/main/kotlin/OrtResult.kt index 0e20010746b8d..1af4bb7080cbe 100644 --- a/model/src/main/kotlin/OrtResult.kt +++ b/model/src/main/kotlin/OrtResult.kt @@ -22,7 +22,9 @@ package org.ossreviewtoolkit.model import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonInclude -import org.apache.logging.log4j.kotlin.Logging +import java.lang.invoke.MethodHandles + +import org.apache.logging.log4j.kotlin.loggerOf import org.ossreviewtoolkit.model.ResolvedPackageCurations.Companion.REPOSITORY_CONFIGURATION_PROVIDER_ID import org.ossreviewtoolkit.model.config.Excludes @@ -81,7 +83,7 @@ data class OrtResult( @JsonInclude(JsonInclude.Include.NON_EMPTY) val labels: Map = emptyMap() ) { - companion object : Logging { + companion object { /** * A constant for an [OrtResult] with an empty repository and all other properties `null`. */ @@ -557,6 +559,8 @@ data class OrtResult( ) } +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + /** * Return a set containing exactly one [CuratedPackage] for each given [Package], derived from applying all * given [curations] to the packages they apply to. The given [curations] must be ordered highest-priority-first, which @@ -577,7 +581,7 @@ private fun applyPackageCurations( return packages.mapTo(mutableSetOf()) { pkg -> curationsForId[pkg.id].orEmpty().asReversed().fold(pkg.toCuratedPackage()) { cur, packageCuration -> - OrtResult.logger.debug { + logger.debug { "Applying curation '$packageCuration' to package '${pkg.id.toCoordinates()}'." } diff --git a/model/src/main/kotlin/PackageCuration.kt b/model/src/main/kotlin/PackageCuration.kt index 226b0e0327159..9c7108dd9956e 100644 --- a/model/src/main/kotlin/PackageCuration.kt +++ b/model/src/main/kotlin/PackageCuration.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.model import com.fasterxml.jackson.annotation.JsonProperty -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.utils.ort.showStackTrace @@ -53,8 +53,6 @@ data class PackageCuration( @JsonProperty("curations") val data: PackageCurationData ) { - private companion object : Logging - /** * Return true if this [PackageCuration] is applicable to the package with the given [identifier][pkgId], * disregarding the version. diff --git a/model/src/main/kotlin/ScannerRun.kt b/model/src/main/kotlin/ScannerRun.kt index e99087a11ec5f..916d5f37988ec 100644 --- a/model/src/main/kotlin/ScannerRun.kt +++ b/model/src/main/kotlin/ScannerRun.kt @@ -27,7 +27,7 @@ import java.time.Instant import kotlin.time.measureTimedValue -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.config.ScannerConfiguration import org.ossreviewtoolkit.model.utils.FileListSortedSetConverter @@ -89,7 +89,7 @@ data class ScannerRun( @JsonSerialize(converter = FileListSortedSetConverter::class) val files: Set ) { - companion object : Logging { + companion object { /** * A constant for a [ScannerRun] where all properties are empty. */ diff --git a/model/src/main/kotlin/config/FileArchiverConfiguration.kt b/model/src/main/kotlin/config/FileArchiverConfiguration.kt index 0a3978f76309b..93dd19651149e 100644 --- a/model/src/main/kotlin/config/FileArchiverConfiguration.kt +++ b/model/src/main/kotlin/config/FileArchiverConfiguration.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.model.config -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.utils.DatabaseUtils import org.ossreviewtoolkit.model.utils.FileArchiver @@ -47,7 +47,7 @@ data class FileArchiverConfiguration( */ val postgresStorage: PostgresStorageConfiguration? = null ) { - companion object : Logging { + companion object { const val ARCHIVE_FILENAME = "archive.zip" const val TABLE_NAME = "file_archives" } diff --git a/model/src/main/kotlin/config/FileListStorageConfiguration.kt b/model/src/main/kotlin/config/FileListStorageConfiguration.kt index 8517008d68a74..8cf9cffd9d170 100644 --- a/model/src/main/kotlin/config/FileListStorageConfiguration.kt +++ b/model/src/main/kotlin/config/FileListStorageConfiguration.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.model.config -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.utils.DatabaseUtils import org.ossreviewtoolkit.model.utils.FileProvenanceFileStorage @@ -43,8 +43,6 @@ data class FileListStorageConfiguration( */ val postgresStorage: PostgresStorageConfiguration? = null ) { - private companion object : Logging - init { if (fileStorage != null && postgresStorage != null) { logger.warn { diff --git a/model/src/main/kotlin/config/OrtConfiguration.kt b/model/src/main/kotlin/config/OrtConfiguration.kt index a2e4efada8cdc..1d38a4e79e20a 100644 --- a/model/src/main/kotlin/config/OrtConfiguration.kt +++ b/model/src/main/kotlin/config/OrtConfiguration.kt @@ -26,7 +26,7 @@ import com.sksamuel.hoplite.fp.getOrElse import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Severity import org.ossreviewtoolkit.utils.common.EnvironmentVariableFilter @@ -139,7 +139,7 @@ data class OrtConfiguration( */ val notifier: NotifierConfiguration = NotifierConfiguration() ) { - companion object : Logging { + companion object { /** * Load the [OrtConfiguration]. The different sources are used with this priority: * diff --git a/model/src/main/kotlin/config/ProvenanceStorageConfiguration.kt b/model/src/main/kotlin/config/ProvenanceStorageConfiguration.kt index 3b1f37033034b..e583f964b17b8 100644 --- a/model/src/main/kotlin/config/ProvenanceStorageConfiguration.kt +++ b/model/src/main/kotlin/config/ProvenanceStorageConfiguration.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.model.config -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * Configuration of the storage to use for provenance information. @@ -35,8 +35,6 @@ data class ProvenanceStorageConfiguration( */ val postgresStorage: PostgresStorageConfiguration? = null ) { - private companion object : Logging - init { if (fileStorage != null && postgresStorage != null) { logger.warn { diff --git a/model/src/main/kotlin/utils/ConfigurationResolver.kt b/model/src/main/kotlin/utils/ConfigurationResolver.kt index dc8c07a81ce38..2bc2be4ef6391 100644 --- a/model/src/main/kotlin/utils/ConfigurationResolver.kt +++ b/model/src/main/kotlin/utils/ConfigurationResolver.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.model.utils import kotlin.time.measureTimedValue -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Identifier @@ -35,7 +35,7 @@ import org.ossreviewtoolkit.model.Vulnerability import org.ossreviewtoolkit.model.config.PackageConfiguration import org.ossreviewtoolkit.model.config.Resolutions -object ConfigurationResolver : Logging { +object ConfigurationResolver { /** * Resolved the [PackageConfiguration]s that match the [scan results][scanResultProvider] for the provided * [identifiers]. diff --git a/model/src/main/kotlin/utils/DatabaseUtils.kt b/model/src/main/kotlin/utils/DatabaseUtils.kt index b8349e34278a6..10265df64e737 100644 --- a/model/src/main/kotlin/utils/DatabaseUtils.kt +++ b/model/src/main/kotlin/utils/DatabaseUtils.kt @@ -28,7 +28,7 @@ import javax.sql.DataSource import kotlinx.coroutines.Deferred -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Transaction @@ -38,7 +38,7 @@ import org.jetbrains.exposed.sql.transactions.transaction import org.ossreviewtoolkit.model.config.PostgresConnection import org.ossreviewtoolkit.utils.ort.ORT_FULL_NAME -object DatabaseUtils : Logging { +object DatabaseUtils { /** * This map holds the [HikariDataSource] based on the [PostgresConnection]. */ diff --git a/model/src/main/kotlin/utils/DependencyGraphBuilder.kt b/model/src/main/kotlin/utils/DependencyGraphBuilder.kt index 6ad881f1237f3..ea0c3e08699ff 100644 --- a/model/src/main/kotlin/utils/DependencyGraphBuilder.kt +++ b/model/src/main/kotlin/utils/DependencyGraphBuilder.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.model.utils import java.util.LinkedList -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.DependencyGraph import org.ossreviewtoolkit.model.DependencyGraphEdge @@ -104,8 +104,6 @@ class DependencyGraphBuilder( */ private val dependencyHandler: DependencyHandler ) { - private companion object : Logging - /** * A list storing the identifiers of all dependencies added to this builder. This list is then used to resolve * dependencies based on their indices. diff --git a/model/src/main/kotlin/utils/FileArchiver.kt b/model/src/main/kotlin/utils/FileArchiver.kt index 4883156e8276f..28949913dc6e6 100644 --- a/model/src/main/kotlin/utils/FileArchiver.kt +++ b/model/src/main/kotlin/utils/FileArchiver.kt @@ -24,7 +24,7 @@ import java.io.File import kotlin.time.measureTime import kotlin.time.measureTimedValue -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.KnownProvenance import org.ossreviewtoolkit.utils.common.FileMatcher @@ -50,7 +50,7 @@ class FileArchiver( */ private val storage: ProvenanceFileStorage ) { - companion object : Logging { + companion object { val DEFAULT_ARCHIVE_DIR by lazy { ortDataDirectory.resolve("scanner/archive") } } diff --git a/model/src/main/kotlin/utils/FileProvenanceFileStorage.kt b/model/src/main/kotlin/utils/FileProvenanceFileStorage.kt index 7155ea9ff2ab2..0d510cb1b1e19 100644 --- a/model/src/main/kotlin/utils/FileProvenanceFileStorage.kt +++ b/model/src/main/kotlin/utils/FileProvenanceFileStorage.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.model.utils import java.io.InputStream -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.ArtifactProvenance import org.ossreviewtoolkit.model.HashAlgorithm @@ -45,8 +45,6 @@ class FileProvenanceFileStorage( */ private val filename: String ) : ProvenanceFileStorage { - private companion object : Logging - init { require(filename.isNotEmpty()) { "The filename must not be empty." diff --git a/model/src/main/kotlin/utils/PostgresProvenanceFileStorage.kt b/model/src/main/kotlin/utils/PostgresProvenanceFileStorage.kt index de40e45fa77e2..d4397872676d1 100644 --- a/model/src/main/kotlin/utils/PostgresProvenanceFileStorage.kt +++ b/model/src/main/kotlin/utils/PostgresProvenanceFileStorage.kt @@ -23,8 +23,6 @@ import java.io.InputStream import javax.sql.DataSource -import org.apache.logging.log4j.kotlin.Logging - import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.Column import org.jetbrains.exposed.sql.Database @@ -59,8 +57,6 @@ class PostgresProvenanceFileStorage( */ tableName: String ) : ProvenanceFileStorage { - private companion object : Logging - private val table = ProvenanceFileTable(tableName) /** Stores the database connection used by this object. */ diff --git a/notifier/src/main/kotlin/modules/JiraNotifier.kt b/notifier/src/main/kotlin/modules/JiraNotifier.kt index 3f39117832254..44c3987c6435e 100644 --- a/notifier/src/main/kotlin/modules/JiraNotifier.kt +++ b/notifier/src/main/kotlin/modules/JiraNotifier.kt @@ -29,7 +29,7 @@ import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientF import java.net.URI -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.config.JiraConfiguration import org.ossreviewtoolkit.utils.common.collectMessages @@ -40,8 +40,6 @@ class JiraNotifier(private val restClient: JiraRestClient) { .createWithBasicHttpAuthentication(URI(config.host), config.username, config.password) ) - private companion object : Logging - /** * Create a [comment] within the issue specified by the [issueKey]. */ diff --git a/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt b/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt index 0b1e15c4a4bd3..f30a410078ff6 100644 --- a/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt +++ b/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt @@ -38,8 +38,6 @@ import kotlin.time.toKotlinDuration import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.advisor.Advisor import org.ossreviewtoolkit.model.FileFormat import org.ossreviewtoolkit.model.utils.DefaultResolutionProvider @@ -59,8 +57,6 @@ class AdvisorCommand : OrtCommand( name = "advise", help = "Check dependencies for security vulnerabilities." ) { - private companion object : Logging - private val ortFile by option( "--ort-file", "-i", help = "An ORT result file with an analyzer result to use." diff --git a/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt b/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt index 6dcc1044f574c..da8120df37dec 100644 --- a/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt +++ b/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt @@ -36,7 +36,7 @@ import java.time.Duration import kotlin.time.toKotlinDuration -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.Analyzer import org.ossreviewtoolkit.analyzer.determineEnabledPackageManagers @@ -64,8 +64,6 @@ class AnalyzerCommand : OrtCommand( name = "analyze", help = "Determine dependencies of a software project." ) { - private companion object : Logging - private val inputDir by option( "--input-dir", "-i", help = "The project directory to analyze. As a special case, if only one package manager is enabled, this " + diff --git a/plugins/commands/api/src/main/kotlin/utils/Extensions.kt b/plugins/commands/api/src/main/kotlin/utils/Extensions.kt index 9a56c22e33aeb..722e057c4ecbe 100644 --- a/plugins/commands/api/src/main/kotlin/utils/Extensions.kt +++ b/plugins/commands/api/src/main/kotlin/utils/Extensions.kt @@ -23,11 +23,12 @@ import com.github.ajalt.clikt.core.GroupableOption import com.github.ajalt.mordant.terminal.Terminal import java.io.File +import java.lang.invoke.MethodHandles import kotlin.time.measureTime import kotlin.time.measureTimedValue -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.loggerOf import org.ossreviewtoolkit.model.HashAlgorithm import org.ossreviewtoolkit.model.OrtResult @@ -35,6 +36,8 @@ import org.ossreviewtoolkit.model.readValue import org.ossreviewtoolkit.model.writeValue import org.ossreviewtoolkit.utils.common.formatSizeInMib +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + fun T.group(name: String): T = apply { groupName = name } fun T.inputGroup(): T = group(OPTION_GROUP_INPUT) @@ -46,7 +49,7 @@ fun T.configurationGroup(): T = group(OPTION_GROUP_CONFIGU /** * Read [ortFile] into an [OrtResult] and return it. */ -fun Logging.readOrtResult(ortFile: File): OrtResult { +fun readOrtResult(ortFile: File): OrtResult { logger.debug { "Input ORT result file has SHA-1 hash ${HashAlgorithm.SHA1.calculate(ortFile)}." } val (ortResult, duration) = measureTimedValue { ortFile.readValue() } @@ -59,7 +62,7 @@ fun Logging.readOrtResult(ortFile: File): OrtResult { /** * Write the [ortResult] to all [outputFiles]. */ -fun Logging.writeOrtResult(ortResult: OrtResult, outputFiles: Collection, terminal: Terminal) { +fun writeOrtResult(ortResult: OrtResult, outputFiles: Collection, terminal: Terminal) { outputFiles.forEach { file -> val resultName = file.name.substringBefore('-') terminal.println("Writing $resultName result to '$file'.") diff --git a/plugins/commands/downloader/src/main/kotlin/DownloaderCommand.kt b/plugins/commands/downloader/src/main/kotlin/DownloaderCommand.kt index 9bc78a6a907ad..3b9cdafa0fce2 100644 --- a/plugins/commands/downloader/src/main/kotlin/DownloaderCommand.kt +++ b/plugins/commands/downloader/src/main/kotlin/DownloaderCommand.kt @@ -44,7 +44,7 @@ import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.DownloadException import org.ossreviewtoolkit.downloader.Downloader @@ -87,8 +87,6 @@ class DownloaderCommand : OrtCommand( name = "download", help = "Fetch source code from a remote location." ) { - private companion object : Logging - private val input by mutuallyExclusiveOptions( option( "--ort-file", "-i", diff --git a/plugins/commands/evaluator/src/main/kotlin/EvaluatorCommand.kt b/plugins/commands/evaluator/src/main/kotlin/EvaluatorCommand.kt index 8158eab4bc422..348144ca1d86d 100644 --- a/plugins/commands/evaluator/src/main/kotlin/EvaluatorCommand.kt +++ b/plugins/commands/evaluator/src/main/kotlin/EvaluatorCommand.kt @@ -37,7 +37,7 @@ import java.time.Duration import kotlin.time.toKotlinDuration -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.evaluator.Evaluator import org.ossreviewtoolkit.model.FileFormat @@ -84,8 +84,6 @@ class EvaluatorCommand : OrtCommand( name = "evaluate", help = "Evaluate ORT result files against policy rules." ) { - private companion object : Logging - private val ortFile by option( "--ort-file", "-i", help = "The ORT result file to read as input." diff --git a/plugins/commands/notifier/src/main/kotlin/NotifierCommand.kt b/plugins/commands/notifier/src/main/kotlin/NotifierCommand.kt index a0c22a6e3ed77..5dc0ff5c43be6 100644 --- a/plugins/commands/notifier/src/main/kotlin/NotifierCommand.kt +++ b/plugins/commands/notifier/src/main/kotlin/NotifierCommand.kt @@ -27,8 +27,6 @@ import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required import com.github.ajalt.clikt.parameters.types.file -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.model.utils.DefaultResolutionProvider import org.ossreviewtoolkit.model.utils.mergeLabels import org.ossreviewtoolkit.notifier.Notifier @@ -45,8 +43,6 @@ class NotifierCommand : OrtCommand( name = "notify", help = "Create notifications based on an ORT result." ) { - private companion object : Logging - private val ortFile by option( "--ort-file", "-i", help = "The ORT result file to read as input." diff --git a/plugins/commands/reporter/src/main/kotlin/ReporterCommand.kt b/plugins/commands/reporter/src/main/kotlin/ReporterCommand.kt index c2d568749c54c..ee0f2389c98b3 100644 --- a/plugins/commands/reporter/src/main/kotlin/ReporterCommand.kt +++ b/plugins/commands/reporter/src/main/kotlin/ReporterCommand.kt @@ -38,7 +38,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.config.CopyrightGarbage import org.ossreviewtoolkit.model.config.LicenseFilePatterns @@ -79,8 +79,6 @@ class ReporterCommand : OrtCommand( name = "report", help = "Present Analyzer, Scanner and Evaluator results in various formats." ) { - private companion object : Logging - private val ortFile by option( "--ort-file", "-i", help = "The ORT result file to use." diff --git a/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt b/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt index 293d82ef75c65..0eb516fbd6e04 100644 --- a/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt +++ b/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt @@ -25,7 +25,7 @@ import com.github.ajalt.mordant.rendering.Theme import java.io.File import java.lang.reflect.Modifier -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.PackageManager import org.ossreviewtoolkit.downloader.VersionControlSystem @@ -49,8 +49,6 @@ class RequirementsCommand : OrtCommand( name = "requirements", help = "Check for the command line tools required by ORT." ) { - private companion object : Logging - override fun run() { val reflections = Reflections("org.ossreviewtoolkit") val classes = reflections.getSubTypesOf(CommandLineTool::class.java) diff --git a/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt b/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt index 2061767d756fc..b164d73b979cb 100644 --- a/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt +++ b/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt @@ -42,7 +42,7 @@ import kotlin.time.toKotlinDuration import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.FileFormat import org.ossreviewtoolkit.model.OrtResult @@ -75,8 +75,6 @@ class ScannerCommand : OrtCommand( name = "scan", help = "Run external license / copyright scanners." ) { - private companion object : Logging - private val input by mutuallyExclusiveOptions( option( "--ort-file", "-i", diff --git a/plugins/commands/upload-curations/src/main/kotlin/UploadCurationsCommand.kt b/plugins/commands/upload-curations/src/main/kotlin/UploadCurationsCommand.kt index 89501e3d1bde8..e40685e36d922 100644 --- a/plugins/commands/upload-curations/src/main/kotlin/UploadCurationsCommand.kt +++ b/plugins/commands/upload-curations/src/main/kotlin/UploadCurationsCommand.kt @@ -29,7 +29,7 @@ import com.github.ajalt.clikt.parameters.types.file import java.net.URI -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.clearlydefined.ClearlyDefinedService import org.ossreviewtoolkit.clients.clearlydefined.ClearlyDefinedService.ContributionInfo @@ -59,8 +59,6 @@ class UploadCurationsCommand : OrtCommand( name = "upload-curations", help = "Upload ORT package curations to ClearlyDefined." ) { - private companion object : Logging - private val inputFile by option( "--input-file", "-i", help = "The file with package curations to upload." diff --git a/plugins/commands/upload-result-to-postgres/src/main/kotlin/UploadResultToPostgresCommand.kt b/plugins/commands/upload-result-to-postgres/src/main/kotlin/UploadResultToPostgresCommand.kt index 73758e0b96125..5102213373ed9 100644 --- a/plugins/commands/upload-result-to-postgres/src/main/kotlin/UploadResultToPostgresCommand.kt +++ b/plugins/commands/upload-result-to-postgres/src/main/kotlin/UploadResultToPostgresCommand.kt @@ -27,8 +27,6 @@ import com.github.ajalt.clikt.parameters.types.file import java.sql.SQLException -import org.apache.logging.log4j.kotlin.Logging - import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.SchemaUtils @@ -53,8 +51,6 @@ class UploadResultToPostgresCommand : OrtCommand( name = "upload-result-to-postgres", help = "Upload an ORT result to a PostgreSQL database." ) { - private companion object : Logging - private val ortFile by option( "--ort-file", "-i", help = "The ORT result file to read as input." diff --git a/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt b/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt index f197f8b3e5526..1aff94020d40b 100644 --- a/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt +++ b/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt @@ -25,7 +25,7 @@ import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required import com.github.ajalt.clikt.parameters.types.file -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.eclipse.sw360.clients.adapter.AttachmentUploadRequest import org.eclipse.sw360.clients.adapter.SW360ProjectClientAdapter @@ -57,8 +57,6 @@ class UploadResultToSw360Command : OrtCommand( name = "upload-result-to-sw360", help = "Upload an ORT result to SW360." ) { - private companion object : Logging - private val ortFile by option( "--ort-file", "-i", help = "The ORT result file to read as input." diff --git a/plugins/package-configuration-providers/dir/src/main/kotlin/DirPackageConfigurationProvider.kt b/plugins/package-configuration-providers/dir/src/main/kotlin/DirPackageConfigurationProvider.kt index 0cdbcb14a51e6..2a03da57b2e79 100644 --- a/plugins/package-configuration-providers/dir/src/main/kotlin/DirPackageConfigurationProvider.kt +++ b/plugins/package-configuration-providers/dir/src/main/kotlin/DirPackageConfigurationProvider.kt @@ -22,8 +22,6 @@ package org.ossreviewtoolkit.plugins.packageconfigurationproviders.dir import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.model.FileFormat import org.ossreviewtoolkit.model.config.PackageConfiguration import org.ossreviewtoolkit.model.readValue @@ -81,7 +79,7 @@ class DirPackageConfigurationProvider( config.path.takeUnless { !it.exists() && !config.mustExist } ) - companion object : Logging { + companion object { fun readConfigurationFiles(paths: Collection): List { val allConfigurations = mutableListOf>() diff --git a/plugins/package-configuration-providers/ort-config/src/main/kotlin/OrtConfigPackageConfigurationProvider.kt b/plugins/package-configuration-providers/ort-config/src/main/kotlin/OrtConfigPackageConfigurationProvider.kt index d43545b2c003a..d44c08a9af5aa 100644 --- a/plugins/package-configuration-providers/ort-config/src/main/kotlin/OrtConfigPackageConfigurationProvider.kt +++ b/plugins/package-configuration-providers/ort-config/src/main/kotlin/OrtConfigPackageConfigurationProvider.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.plugins.packageconfigurationproviders.ortconfig import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.vcs.Git import org.ossreviewtoolkit.model.Identifier @@ -53,8 +53,6 @@ class OrtConfigPackageConfigurationProviderFactory : PackageConfigurationProvide * [ort-config repository](https://github.com/oss-review-toolkit/ort-config). */ class OrtConfigPackageConfigurationProvider : PackageConfigurationProvider { - internal companion object : Logging - private val configurationsDir by lazy { ortDataDirectory.resolve("ort-config").also { updateOrtConfig(it) @@ -74,7 +72,7 @@ private fun updateOrtConfig(dir: File) { Git().apply { val workingTree = initWorkingTree(dir, VcsInfo.EMPTY.copy(type = VcsType.GIT, url = ORT_CONFIG_REPOSITORY_URL)) val revision = updateWorkingTree(workingTree, ORT_CONFIG_REPOSITORY_BRANCH).getOrThrow() - OrtConfigPackageConfigurationProvider.logger.info { + logger.info { "Successfully cloned $revision from $ORT_CONFIG_REPOSITORY_URL." } } diff --git a/plugins/package-curation-providers/clearly-defined/src/main/kotlin/ClearlyDefinedPackageCurationProvider.kt b/plugins/package-curation-providers/clearly-defined/src/main/kotlin/ClearlyDefinedPackageCurationProvider.kt index 14efe97b5e85a..fbefeae806af7 100644 --- a/plugins/package-curation-providers/clearly-defined/src/main/kotlin/ClearlyDefinedPackageCurationProvider.kt +++ b/plugins/package-curation-providers/clearly-defined/src/main/kotlin/ClearlyDefinedPackageCurationProvider.kt @@ -23,7 +23,7 @@ import java.net.HttpURLConnection import okhttp3.OkHttpClient -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.clearlydefined.ClearlyDefinedService import org.ossreviewtoolkit.clients.clearlydefined.ClearlyDefinedService.Server @@ -85,8 +85,6 @@ class ClearlyDefinedPackageCurationProvider( private val config: ClearlyDefinedPackageCurationProviderConfig, client: OkHttpClient? = null ) : PackageCurationProvider { - private companion object : Logging - constructor(serverUrl: String, client: OkHttpClient? = null) : this( ClearlyDefinedPackageCurationProviderConfig(serverUrl, minTotalLicenseScore = 0), client ) diff --git a/plugins/package-curation-providers/file/src/main/kotlin/FilePackageCurationProvider.kt b/plugins/package-curation-providers/file/src/main/kotlin/FilePackageCurationProvider.kt index e6478cecf6610..58d89c3f3c192 100644 --- a/plugins/package-curation-providers/file/src/main/kotlin/FilePackageCurationProvider.kt +++ b/plugins/package-curation-providers/file/src/main/kotlin/FilePackageCurationProvider.kt @@ -22,8 +22,6 @@ package org.ossreviewtoolkit.plugins.packagecurationproviders.file import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.model.FileFormat import org.ossreviewtoolkit.model.PackageCuration import org.ossreviewtoolkit.model.readValue @@ -91,7 +89,7 @@ class FilePackageCurationProvider( config.path.takeUnless { !it.exists() && !config.mustExist } ) - companion object : Logging { + companion object { /** * Read a list of [PackageCuration]s from existing [paths], which can either point to files or directories. In * the latter case, the directory is searched recursively for deserializable files (according to their diff --git a/plugins/package-curation-providers/ort-config/src/main/kotlin/OrtConfigPackageCurationProvider.kt b/plugins/package-curation-providers/ort-config/src/main/kotlin/OrtConfigPackageCurationProvider.kt index 94b4c66a864f0..81e61a4be3b4a 100644 --- a/plugins/package-curation-providers/ort-config/src/main/kotlin/OrtConfigPackageCurationProvider.kt +++ b/plugins/package-curation-providers/ort-config/src/main/kotlin/OrtConfigPackageCurationProvider.kt @@ -22,7 +22,7 @@ package org.ossreviewtoolkit.plugins.packagecurationproviders.ortconfig import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.vcs.Git import org.ossreviewtoolkit.model.Identifier @@ -54,8 +54,6 @@ class OrtConfigPackageCurationProviderFactory : PackageCurationProviderFactory("Cargo") { override val globsForDefinitionFiles = listOf("Cargo.toml") diff --git a/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt b/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt index cc6ef0a644126..c943d83e64b56 100644 --- a/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt +++ b/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt @@ -30,7 +30,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -79,8 +79,6 @@ class CocoaPods( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("CocoaPods") { override val globsForDefinitionFiles = listOf("Podfile") diff --git a/plugins/package-managers/composer/src/main/kotlin/Composer.kt b/plugins/package-managers/composer/src/main/kotlin/Composer.kt index acecbb5b7e0dc..c7501673861bd 100644 --- a/plugins/package-managers/composer/src/main/kotlin/Composer.kt +++ b/plugins/package-managers/composer/src/main/kotlin/Composer.kt @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -71,8 +71,6 @@ class Composer( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("Composer") { override val globsForDefinitionFiles = listOf("composer.json") diff --git a/plugins/package-managers/conan/src/main/kotlin/Conan.kt b/plugins/package-managers/conan/src/main/kotlin/Conan.kt index ab3e83ef290b3..0dd0931f9c672 100644 --- a/plugins/package-managers/conan/src/main/kotlin/Conan.kt +++ b/plugins/package-managers/conan/src/main/kotlin/Conan.kt @@ -24,7 +24,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -74,7 +74,7 @@ class Conan( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - companion object : Logging { + companion object { /** * The name of the option to specify the name of the lockfile. */ diff --git a/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt b/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt index ed77c926c6cc9..798ff436d58ae 100644 --- a/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt +++ b/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt @@ -27,7 +27,7 @@ import java.io.File import java.util.Properties import java.util.concurrent.TimeUnit -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.gradle.tooling.GradleConnector import org.gradle.tooling.events.ProgressListener @@ -99,8 +99,6 @@ class GradleInspector( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig) { - internal companion object : Logging - class Factory : AbstractPackageManagerFactory("GradleInspector", isEnabledByDefault = false) { // Gradle prefers Groovy ".gradle" files over Kotlin ".gradle.kts" files, but "build" files have to come before // "settings" files as we should consider "settings" files only if the same directory does not also contain a @@ -428,7 +426,7 @@ private fun OrtDependency.handleValidScmInfo(type: String, url: String, tag: Str // Try to detect the Maven SCM provider from the URL only, e.g. by looking at the host or special URL paths. VcsHost.parseUrl(fixedUrl).copy(revision = tag).also { - GradleInspector.logger.info { + logger.info { "Fixed up invalid SCM connection without a provider in '$groupId:$artifactId:$version' to $it." } } @@ -468,14 +466,14 @@ private fun OrtDependency.handleInvalidScmInfo(connection: String, tag: String) if (connection.startsWith("git://") || connection.endsWith(".git")) { // It is a common mistake to omit the "scm:[provider]:" prefix. Add fall-backs for nevertheless clear // cases. - GradleInspector.logger.info { + logger.info { "Maven SCM connection '$connection' in '$dep' lacks the required 'scm' prefix." } VcsInfo(type = VcsType.GIT, url = connection, revision = tag) } else { if (connection.isNotEmpty()) { - GradleInspector.logger.info { + logger.info { "Ignoring Maven SCM connection '$connection' in '$dep' due to an unexpected format." } } diff --git a/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt b/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt index bbce0b4d98474..204df42094c31 100644 --- a/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt +++ b/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt @@ -26,7 +26,7 @@ import java.io.File import java.util.Properties import java.util.concurrent.TimeUnit -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.eclipse.aether.artifact.Artifact import org.eclipse.aether.repository.RemoteRepository @@ -81,7 +81,7 @@ class Gradle( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig) { - companion object : Logging { + companion object { /** * The name of the option to specify the Gradle version. */ diff --git a/plugins/package-managers/gradle/src/main/kotlin/GradleDependencyHandler.kt b/plugins/package-managers/gradle/src/main/kotlin/GradleDependencyHandler.kt index 8350731c3b648..6e38521a8b3d1 100644 --- a/plugins/package-managers/gradle/src/main/kotlin/GradleDependencyHandler.kt +++ b/plugins/package-managers/gradle/src/main/kotlin/GradleDependencyHandler.kt @@ -21,7 +21,6 @@ package org.ossreviewtoolkit.plugins.packagemanagers.gradle import OrtDependency -import org.apache.logging.log4j.kotlin.Logging import org.apache.maven.project.ProjectBuildingException import org.eclipse.aether.RepositoryException @@ -50,8 +49,6 @@ internal class GradleDependencyHandler( /** The helper object to resolve packages via Maven. */ private val maven: MavenSupport ) : DependencyHandler { - private companion object : Logging - /** * A list with repositories to use when resolving packages. This list must be set before using this handler for * constructing the dependency graph of a project. As different projects may use different repositories, this diff --git a/plugins/package-managers/node/src/main/kotlin/Npm.kt b/plugins/package-managers/node/src/main/kotlin/Npm.kt index 34b2d36849f15..d4cd70fcd2f77 100644 --- a/plugins/package-managers/node/src/main/kotlin/Npm.kt +++ b/plugins/package-managers/node/src/main/kotlin/Npm.kt @@ -34,7 +34,7 @@ import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -107,7 +107,7 @@ open class Npm( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - companion object : Logging { + companion object { /** Name of the configuration option to toggle legacy peer dependency support. */ const val OPTION_LEGACY_PEER_DEPS = "legacyPeerDeps" } diff --git a/plugins/package-managers/node/src/main/kotlin/Yarn.kt b/plugins/package-managers/node/src/main/kotlin/Yarn.kt index 233d44eed54a2..a30e4d4f88bf0 100644 --- a/plugins/package-managers/node/src/main/kotlin/Yarn.kt +++ b/plugins/package-managers/node/src/main/kotlin/Yarn.kt @@ -25,7 +25,7 @@ import java.io.File import kotlin.time.Duration.Companion.days -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.model.config.AnalyzerConfiguration @@ -56,8 +56,6 @@ class Yarn( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : Npm(name, analysisRoot, analyzerConfig, repoConfig) { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("Yarn") { override val globsForDefinitionFiles = listOf("package.json") diff --git a/plugins/package-managers/node/src/main/kotlin/Yarn2.kt b/plugins/package-managers/node/src/main/kotlin/Yarn2.kt index 6e8d92a8909de..10fe6effd94eb 100644 --- a/plugins/package-managers/node/src/main/kotlin/Yarn2.kt +++ b/plugins/package-managers/node/src/main/kotlin/Yarn2.kt @@ -32,7 +32,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -93,7 +93,7 @@ class Yarn2( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - companion object : Logging { + companion object { /** * The name of the option to disable HTTPS server certificate verification. */ diff --git a/plugins/package-managers/node/src/main/kotlin/utils/NpmSupport.kt b/plugins/package-managers/node/src/main/kotlin/utils/NpmSupport.kt index 86049f89d5156..8d9ef4b7671a4 100644 --- a/plugins/package-managers/node/src/main/kotlin/utils/NpmSupport.kt +++ b/plugins/package-managers/node/src/main/kotlin/utils/NpmSupport.kt @@ -27,10 +27,11 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode import java.io.File +import java.lang.invoke.MethodHandles import java.nio.file.FileSystems import java.nio.file.PathMatcher -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.loggerOf import org.ossreviewtoolkit.analyzer.parseAuthorString import org.ossreviewtoolkit.model.VcsInfo @@ -44,12 +45,7 @@ import org.ossreviewtoolkit.utils.common.toUri import org.ossreviewtoolkit.utils.ort.showStackTrace import org.ossreviewtoolkit.utils.spdx.SpdxConstants -/** - * A dummy object to provide a logger for top-level functions. - * - * TODO: Remove this once https://youtrack.jetbrains.com/issue/KT-21599 is implemented. - */ -internal object NpmSupport : Logging +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) /** * Expand an NPM shortcut [url] to a regular URL as used for dependencies, see @@ -196,7 +192,7 @@ private fun getPackageJsonInfo(definitionFiles: Set): Collection): Set { } catch (e: JsonProcessingException) { e.showStackTrace() - NpmSupport.logger.error { - "Could not parse '${definitionFile.invariantSeparatorsPath}': ${e.collectMessages()}" - } + logger.error { "Could not parse '${definitionFile.invariantSeparatorsPath}': ${e.collectMessages()}" } null } diff --git a/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt b/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt index 38c885c665722..eeaf5ef5e17f2 100644 --- a/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt +++ b/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt @@ -21,8 +21,6 @@ package org.ossreviewtoolkit.plugins.packagemanagers.nuget import java.io.File -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager import org.ossreviewtoolkit.model.Issue @@ -44,7 +42,7 @@ class NuGet( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig) { - companion object : Logging { + companion object { const val OPTION_NUGET_CONFIG = "nugetConfigFile" } diff --git a/plugins/package-managers/pub/src/main/kotlin/Pub.kt b/plugins/package-managers/pub/src/main/kotlin/Pub.kt index 5b1e07223ee96..ffc31ea64bcf8 100644 --- a/plugins/package-managers/pub/src/main/kotlin/Pub.kt +++ b/plugins/package-managers/pub/src/main/kotlin/Pub.kt @@ -25,7 +25,7 @@ import com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException import java.io.File import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -107,7 +107,7 @@ class Pub( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - companion object : Logging { + companion object { const val OPTION_PUB_DEPENDENCIES_ONLY = "pubDependenciesOnly" } diff --git a/plugins/package-managers/pub/src/main/kotlin/utils/PubCacheReader.kt b/plugins/package-managers/pub/src/main/kotlin/utils/PubCacheReader.kt index 9088621ac3072..4c9ed26e26678 100644 --- a/plugins/package-managers/pub/src/main/kotlin/utils/PubCacheReader.kt +++ b/plugins/package-managers/pub/src/main/kotlin/utils/PubCacheReader.kt @@ -23,7 +23,7 @@ import com.fasterxml.jackson.databind.JsonNode import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.VcsHost import org.ossreviewtoolkit.plugins.packagemanagers.pub.flutterHome @@ -37,8 +37,6 @@ import org.ossreviewtoolkit.utils.common.textValueOrEmpty * installation directory. */ internal class PubCacheReader { - private companion object : Logging - private val pubCacheRoot by lazy { Os.env["PUB_CACHE"]?.let { return@lazy File(it) } diff --git a/plugins/package-managers/python/src/main/kotlin/Pip.kt b/plugins/package-managers/python/src/main/kotlin/Pip.kt index f01bc7bff4acb..d3674a11bc8dd 100644 --- a/plugins/package-managers/python/src/main/kotlin/Pip.kt +++ b/plugins/package-managers/python/src/main/kotlin/Pip.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.plugins.packagemanagers.python import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -58,7 +58,7 @@ class Pip( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig) { - companion object : Logging { + companion object { const val OPTION_OPERATING_SYSTEM = "operatingSystem" const val OPTION_PYTHON_VERSION = "pythonVersion" } diff --git a/plugins/package-managers/python/src/main/kotlin/Pipenv.kt b/plugins/package-managers/python/src/main/kotlin/Pipenv.kt index ef17d4dbed934..2875047bc5edb 100644 --- a/plugins/package-managers/python/src/main/kotlin/Pipenv.kt +++ b/plugins/package-managers/python/src/main/kotlin/Pipenv.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.plugins.packagemanagers.python import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -46,8 +46,6 @@ class Pipenv( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("Pipenv") { override val globsForDefinitionFiles = listOf("Pipfile.lock") diff --git a/plugins/package-managers/python/src/main/kotlin/Poetry.kt b/plugins/package-managers/python/src/main/kotlin/Poetry.kt index 0bab26e3b7b4d..eaef43e3e358e 100644 --- a/plugins/package-managers/python/src/main/kotlin/Poetry.kt +++ b/plugins/package-managers/python/src/main/kotlin/Poetry.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.plugins.packagemanagers.python import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -42,8 +42,6 @@ class Poetry( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig), CommandLineTool { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("Poetry") { override val globsForDefinitionFiles = listOf("poetry.lock") diff --git a/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt b/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt index 0e088ffd2fd94..c9868f4fec338 100644 --- a/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt +++ b/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt @@ -27,8 +27,6 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonNamingStrategy import kotlinx.serialization.json.decodeFromStream -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.utils.common.CommandLineTool import org.ossreviewtoolkit.utils.ort.createOrtTempFile @@ -40,7 +38,7 @@ private val json = Json { namingStrategy = JsonNamingStrategy.SnakeCase } -internal object PythonInspector : CommandLineTool, Logging { +internal object PythonInspector : CommandLineTool { override fun command(workingDir: File?) = "python-inspector" override fun transformVersion(output: String) = output.removePrefix("Python-inspector version: ") diff --git a/plugins/package-managers/python/src/main/kotlin/utils/PythonUtils.kt b/plugins/package-managers/python/src/main/kotlin/utils/PythonUtils.kt index 82b24fde1a52c..cb2e605798f40 100644 --- a/plugins/package-managers/python/src/main/kotlin/utils/PythonUtils.kt +++ b/plugins/package-managers/python/src/main/kotlin/utils/PythonUtils.kt @@ -19,11 +19,17 @@ package org.ossreviewtoolkit.plugins.packagemanagers.python.utils +import java.lang.invoke.MethodHandles + +import org.apache.logging.log4j.kotlin.loggerOf + import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.utils.ort.DeclaredLicenseProcessor import org.ossreviewtoolkit.utils.ort.ProcessedDeclaredLicense import org.ossreviewtoolkit.utils.spdx.SpdxLicenseIdExpression +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + private const val GENERIC_BSD_LICENSE = "BSD License" private const val SHORT_STRING_MAX_CHARS = 200 @@ -56,7 +62,7 @@ internal fun processDeclaredLicenses(id: Identifier, declaredLicenses: Set - PythonInspector.logger.debug { "Mapping '$GENERIC_BSD_LICENSE' to '$license' for '${id.toCoordinates()}'." } + logger.debug { "Mapping '$GENERIC_BSD_LICENSE' to '$license' for '${id.toCoordinates()}'." } declaredLicensesProcessed = declaredLicensesProcessed.copy( mapped = declaredLicensesProcessed.mapped + mapOf(GENERIC_BSD_LICENSE to license), diff --git a/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt b/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt index d4781589453e4..5c18db6840c74 100644 --- a/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt +++ b/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt @@ -23,7 +23,7 @@ package org.ossreviewtoolkit.plugins.packagemanagers.spdx import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -133,7 +133,7 @@ private fun SpdxPackage.getRemoteArtifact(): RemoteArtifact? = SPDX_VCS_PREFIXES.any { (prefix, _) -> downloadLocation.startsWith(prefix) } -> null else -> { if (downloadLocation.endsWith(".git")) { - SpdxDocumentFile.logger.warn { + logger.warn { "The download location $downloadLocation of SPDX package '$spdxId' looks like a Git repository " + "URL but it lacks the 'git+' prefix and thus will be treated as an artifact URL." } @@ -267,8 +267,6 @@ class SpdxDocumentFile( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(managerName, analysisRoot, analyzerConfig, repoConfig) { - internal companion object : Logging - class Factory : AbstractPackageManagerFactory(MANAGER_NAME) { override val globsForDefinitionFiles = listOf("*.spdx.yml", "*.spdx.yaml", "*.spdx.json") diff --git a/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxDocumentCache.kt b/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxDocumentCache.kt index fead90ac80ac6..09c5f6c9b899c 100644 --- a/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxDocumentCache.kt +++ b/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxDocumentCache.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.plugins.packagemanagers.spdx.utils import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.plugins.packagemanagers.spdx.SpdxDocumentFile import org.ossreviewtoolkit.utils.spdx.SpdxModelMapper @@ -37,8 +37,6 @@ import org.ossreviewtoolkit.utils.spdx.model.SpdxDocument * Implementation note: This implementation is not thread-safe. */ internal class SpdxDocumentCache { - private companion object : Logging - /** A cache for the documents that have already been loaded. */ private val documentCache = mutableMapOf>() diff --git a/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt b/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt index 3f647a5d146ca..d87499de43a93 100644 --- a/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt +++ b/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt @@ -24,7 +24,7 @@ package org.ossreviewtoolkit.plugins.packagemanagers.spdx.utils import java.io.File import java.net.URI -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Hash import org.ossreviewtoolkit.model.Issue @@ -86,7 +86,7 @@ internal data class SpdxResolvedDocument( */ private val issuesByReferenceId: Map ) { - companion object : Logging { + companion object { fun load(cache: SpdxDocumentCache, rootDocumentFile: File, managerName: String): SpdxResolvedDocument { val rootDocument = cache.load(rootDocumentFile).getOrThrow() @@ -335,7 +335,7 @@ private fun SpdxExternalDocumentReference.resolveFromDownload( baseUri: URI, managerName: String ): ResolutionResult { - SpdxResolvedDocument.logger.info { + logger.info { "Downloading SPDX document from $uri (referred from $baseUri as part of '$externalDocumentId')." } diff --git a/plugins/package-managers/spm/src/main/kotlin/SpmModel.kt b/plugins/package-managers/spm/src/main/kotlin/SpmModel.kt index 27f4c97d36cf0..7d4c835cea36c 100644 --- a/plugins/package-managers/spm/src/main/kotlin/SpmModel.kt +++ b/plugins/package-managers/spm/src/main/kotlin/SpmModel.kt @@ -19,13 +19,15 @@ package org.ossreviewtoolkit.plugins.packagemanagers.spm +import java.lang.invoke.MethodHandles import java.net.URI import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json -import org.ossreviewtoolkit.analyzer.PackageManager +import org.apache.logging.log4j.kotlin.loggerOf + import org.ossreviewtoolkit.downloader.VcsHost import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.Package @@ -146,6 +148,8 @@ data class AppDependency( } } +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + internal fun parseAuthorAndProjectFromRepo(repositoryURL: String): Pair { val normalizedURL = normalizeVcsUrl(repositoryURL) val vcsHost = VcsHost.fromUrl(URI(normalizedURL)) @@ -153,13 +157,13 @@ internal fun parseAuthorAndProjectFromRepo(repositoryURL: String): Pair("Stack") { override val globsForDefinitionFiles = listOf("stack.yaml") diff --git a/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt b/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt index 1795ccd5fca1e..7157af61f39f8 100644 --- a/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt +++ b/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.plugins.packagemanagers.unmanaged import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory import org.ossreviewtoolkit.analyzer.PackageManager @@ -46,8 +46,6 @@ class Unmanaged( analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfiguration ) : PackageManager(name, analysisRoot, analyzerConfig, repoConfig) { - private companion object : Logging - class Factory : AbstractPackageManagerFactory("Unmanaged") { // The empty list returned here deliberately causes this special package manager to never be considered in // PackageManager.findManagedFiles(). Instead, it will only be explicitly instantiated as part of diff --git a/plugins/reporters/fossid/src/main/kotlin/FossIdReporter.kt b/plugins/reporters/fossid/src/main/kotlin/FossIdReporter.kt index 55053a62c18e1..df082991c9593 100644 --- a/plugins/reporters/fossid/src/main/kotlin/FossIdReporter.kt +++ b/plugins/reporters/fossid/src/main/kotlin/FossIdReporter.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.fossid.FossIdRestService import org.ossreviewtoolkit.clients.fossid.generateReport @@ -39,7 +39,7 @@ import org.ossreviewtoolkit.utils.common.collectMessages import org.ossreviewtoolkit.utils.ort.showStackTrace class FossIdReporter : Reporter { - companion object : Logging { + companion object { /** Name of the configuration property for the server URL. */ const val SERVER_URL_PROPERTY = "serverUrl" diff --git a/plugins/reporters/fossid/src/main/kotlin/FossIdSnippetReporter.kt b/plugins/reporters/fossid/src/main/kotlin/FossIdSnippetReporter.kt index 61ad197b0211b..dc03819d2e8ed 100644 --- a/plugins/reporters/fossid/src/main/kotlin/FossIdSnippetReporter.kt +++ b/plugins/reporters/fossid/src/main/kotlin/FossIdSnippetReporter.kt @@ -21,15 +21,13 @@ package org.ossreviewtoolkit.plugins.reporters.fossid import java.io.File -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.plugins.reporters.asciidoc.HtmlTemplateReporter import org.ossreviewtoolkit.plugins.reporters.freemarker.FreemarkerTemplateProcessor import org.ossreviewtoolkit.reporter.Reporter import org.ossreviewtoolkit.reporter.ReporterInput class FossIdSnippetReporter : Reporter by delegateReporter { - companion object : Logging { + companion object { private const val TEMPLATE_NAME = "fossid_snippet" val delegateReporter = HtmlTemplateReporter() diff --git a/plugins/reporters/freemarker/src/main/kotlin/FreemarkerTemplateProcessor.kt b/plugins/reporters/freemarker/src/main/kotlin/FreemarkerTemplateProcessor.kt index dfc86ca51c1f8..f902694f4baa4 100644 --- a/plugins/reporters/freemarker/src/main/kotlin/FreemarkerTemplateProcessor.kt +++ b/plugins/reporters/freemarker/src/main/kotlin/FreemarkerTemplateProcessor.kt @@ -27,7 +27,7 @@ import freemarker.template.TemplateExceptionHandler import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.AdvisorCapability import org.ossreviewtoolkit.model.AdvisorRecord @@ -67,7 +67,7 @@ class FreemarkerTemplateProcessor( private val filePrefix: String = "", private val fileExtension: String = "" ) { - companion object : Logging { + companion object { const val OPTION_TEMPLATE_ID = "template.id" const val OPTION_TEMPLATE_PATH = "template.path" } diff --git a/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt b/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt index 8df5919044819..a6434c029f65a 100644 --- a/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt +++ b/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.plugins.reporters.gitlab -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.OrtResult @@ -34,7 +34,7 @@ import org.ossreviewtoolkit.utils.spdx.SpdxSingleLicenseExpression /** * Maps an [OrtResult] to a [GitLabLicenseModel]. */ -internal object GitLabLicenseModelMapper : Logging { +internal object GitLabLicenseModelMapper { fun map(ortResult: OrtResult, skipExcluded: Boolean): GitLabLicenseModel { val packagesWithDefinitionFilePaths = ortResult.getTargetPackagesWithDefinitionFiles(skipExcluded) @@ -120,6 +120,6 @@ private fun Identifier.toPackageManagerName(): String = "PIP" -> "pip" "Yarn" -> "yarn" else -> type.lowercase().also { - GitLabLicenseModelMapper.logger.info { "No mapping defined for package manager '$type', guessing '$it'." } + logger.info { "No mapping defined for package manager '$type', guessing '$it'." } } } diff --git a/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt b/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt index 906436bc15121..aaccfab4305a5 100644 --- a/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt +++ b/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt @@ -30,7 +30,7 @@ import java.util.UUID import kotlin.math.min -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.VcsHost import org.ossreviewtoolkit.model.CuratedPackage @@ -80,7 +80,7 @@ internal fun resolvePath(pieces: List) = pieces.reduce { right, left -> * - *scanner.maxDepth*: The depth to which the full file level scanner information is added */ class OpossumReporter : Reporter { - companion object : Logging { + companion object { const val OPTION_SCANNER_MAX_DEPTH = "scanner.maxDepth" } @@ -210,8 +210,6 @@ class OpossumReporter : Reporter { val baseUrlsForSources: SortedMap = sortedMapOf(), val externalAttributionSources: SortedMap = sortedMapOf() ) { - private companion object : Logging - fun toJson(): Map<*, *> = sortedMapOf( "metadata" to sortedMapOf( diff --git a/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentModelMapper.kt b/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentModelMapper.kt index 219389650419f..66bf76f0d4fb1 100644 --- a/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentModelMapper.kt +++ b/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentModelMapper.kt @@ -24,8 +24,6 @@ import java.time.temporal.ChronoUnit import java.util.UUID import java.util.concurrent.atomic.AtomicInteger -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.model.OrtResult import org.ossreviewtoolkit.model.SourceCodeOrigin.ARTIFACT import org.ossreviewtoolkit.model.SourceCodeOrigin.VCS @@ -44,7 +42,7 @@ import org.ossreviewtoolkit.utils.spdx.model.SpdxRelationship /** * A class for mapping [OrtResult]s to [SpdxDocument]s. */ -internal object SpdxDocumentModelMapper : Logging { +internal object SpdxDocumentModelMapper { data class SpdxDocumentParams( val documentName: String, val documentComment: String, diff --git a/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentReporter.kt b/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentReporter.kt index 65cab073cdad8..d5cee2b3e810d 100644 --- a/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentReporter.kt +++ b/plugins/reporters/spdx/src/main/kotlin/SpdxDocumentReporter.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.plugins.reporters.spdx import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.reporter.Reporter import org.ossreviewtoolkit.reporter.ReporterInput @@ -48,7 +48,7 @@ import org.ossreviewtoolkit.utils.spdx.model.SpdxDocument * about files containing findings. */ class SpdxDocumentReporter : Reporter { - companion object : Logging { + companion object { const val REPORT_BASE_FILENAME = "bom.spdx" const val OPTION_CREATION_INFO_COMMENT = "creationInfo.comment" diff --git a/plugins/scanners/askalono/src/main/kotlin/Askalono.kt b/plugins/scanners/askalono/src/main/kotlin/Askalono.kt index f8f2a3ab7e99d..a0b7764703434 100644 --- a/plugins/scanners/askalono/src/main/kotlin/Askalono.kt +++ b/plugins/scanners/askalono/src/main/kotlin/Askalono.kt @@ -25,7 +25,7 @@ import java.time.Instant import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeToSequence -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Issue import org.ossreviewtoolkit.model.LicenseFinding @@ -45,8 +45,6 @@ private const val CONFIDENCE_NOTICE = "Confidence threshold not high enough for private val JSON = Json { ignoreUnknownKeys = true } class Askalono internal constructor(name: String, private val options: Options) : CommandLinePathScannerWrapper(name) { - private companion object : Logging - class Factory : ScannerWrapperFactory("Askalono") { override fun create(options: Options) = Askalono(type, options) } diff --git a/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt b/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt index 5e510d1167f66..660b4d7095558 100644 --- a/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt +++ b/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt @@ -24,7 +24,7 @@ import java.time.Instant import kotlinx.serialization.json.Json -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Issue import org.ossreviewtoolkit.model.LicenseFinding @@ -44,7 +44,7 @@ import org.ossreviewtoolkit.utils.ort.createOrtTempDir private val JSON = Json { ignoreUnknownKeys = true } class BoyterLc internal constructor(name: String, private val options: Options) : CommandLinePathScannerWrapper(name) { - companion object : Logging { + companion object { val CONFIGURATION_OPTIONS = listOf( "--confidence", "0.95", // Cut-off value to only get most relevant matches. "--format", "json" diff --git a/plugins/scanners/fossid/src/main/kotlin/FossId.kt b/plugins/scanners/fossid/src/main/kotlin/FossId.kt index f7975cf115f9f..f97b0ff97127c 100644 --- a/plugins/scanners/fossid/src/main/kotlin/FossId.kt +++ b/plugins/scanners/fossid/src/main/kotlin/FossId.kt @@ -34,7 +34,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeoutOrNull -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.fossid.FossIdRestService import org.ossreviewtoolkit.clients.fossid.checkDownloadStatus @@ -98,7 +98,7 @@ class FossId internal constructor( override val name: String, private val config: FossIdConfig ) : PackageScannerWrapper { - companion object : Logging { + companion object { @JvmStatic private val PROJECT_NAME_REGEX = Regex("""^.*/([\w.\-]+?)(?:\.git)?$""") diff --git a/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt b/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt index 066029c52d777..e37fa93f56f61 100644 --- a/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt +++ b/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.plugins.scanners.fossid -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.config.ScannerConfiguration import org.ossreviewtoolkit.utils.common.Options @@ -112,7 +112,7 @@ internal data class FossIdConfig( /** Stores the map with FossID-specific configuration options. */ private val options: Map ) { - companion object : Logging { + companion object { /** Name of the configuration property for the server URL. */ private const val SERVER_URL_PROPERTY = "serverUrl" diff --git a/plugins/scanners/fossid/src/main/kotlin/FossIdNamingProvider.kt b/plugins/scanners/fossid/src/main/kotlin/FossIdNamingProvider.kt index f55c63df1861b..729223fb94521 100644 --- a/plugins/scanners/fossid/src/main/kotlin/FossIdNamingProvider.kt +++ b/plugins/scanners/fossid/src/main/kotlin/FossIdNamingProvider.kt @@ -22,7 +22,7 @@ package org.ossreviewtoolkit.plugins.scanners.fossid import java.time.LocalDateTime import java.time.format.DateTimeFormatter -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * This class provides names for projects and scans when the FossID scanner creates them, following a given pattern. @@ -43,7 +43,7 @@ internal class FossIdNamingProvider( private val namingScanPattern: String?, private val namingConventionVariables: Map ) { - companion object : Logging { + companion object { @JvmStatic val FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss") } diff --git a/plugins/scanners/fossid/src/main/kotlin/FossIdScanResults.kt b/plugins/scanners/fossid/src/main/kotlin/FossIdScanResults.kt index e949b064a791d..9cd111bf58be8 100644 --- a/plugins/scanners/fossid/src/main/kotlin/FossIdScanResults.kt +++ b/plugins/scanners/fossid/src/main/kotlin/FossIdScanResults.kt @@ -19,6 +19,10 @@ package org.ossreviewtoolkit.plugins.scanners.fossid +import java.lang.invoke.MethodHandles + +import org.apache.logging.log4j.kotlin.loggerOf + import org.ossreviewtoolkit.clients.fossid.model.identification.identifiedFiles.IdentifiedFile import org.ossreviewtoolkit.clients.fossid.model.identification.ignored.IgnoredFile import org.ossreviewtoolkit.clients.fossid.model.identification.markedAsIdentified.MarkedAsIdentifiedFile @@ -47,6 +51,8 @@ import org.ossreviewtoolkit.utils.ort.DeclaredLicenseProcessor import org.ossreviewtoolkit.utils.spdx.SpdxConstants import org.ossreviewtoolkit.utils.spdx.toSpdx +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + /** * A data class to hold FossID raw results. */ @@ -214,7 +220,7 @@ private fun urlToPackageType(url: String): PurlType = else -> { PurlType.GENERIC.also { - FossId.logger.warn { + logger.warn { "Cannot determine PURL type for url '$url' and provider '$provider'. Falling back to '$it'." } } diff --git a/plugins/scanners/fossid/src/main/kotlin/FossIdUrlProvider.kt b/plugins/scanners/fossid/src/main/kotlin/FossIdUrlProvider.kt index d5bbd63df849e..0ed23ac08c242 100644 --- a/plugins/scanners/fossid/src/main/kotlin/FossIdUrlProvider.kt +++ b/plugins/scanners/fossid/src/main/kotlin/FossIdUrlProvider.kt @@ -22,7 +22,7 @@ package org.ossreviewtoolkit.plugins.scanners.fossid import java.net.Authenticator import java.net.PasswordAuthentication -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.utils.common.percentEncode import org.ossreviewtoolkit.utils.common.replaceCredentialsInUri @@ -43,7 +43,7 @@ internal class FossIdUrlProvider private constructor( */ private val urlMapping: Map ) { - companion object : Logging { + companion object { /** The prefix of option keys that define a URL mapping. */ internal const val PREFIX_URL_MAPPING = "urlMapping" diff --git a/plugins/scanners/fossid/src/main/kotlin/Utils.kt b/plugins/scanners/fossid/src/main/kotlin/Utils.kt index 4ff8d2688d154..02af0ee3b595d 100644 --- a/plugins/scanners/fossid/src/main/kotlin/Utils.kt +++ b/plugins/scanners/fossid/src/main/kotlin/Utils.kt @@ -19,6 +19,10 @@ package org.ossreviewtoolkit.plugins.scanners.fossid +import java.lang.invoke.MethodHandles + +import org.apache.logging.log4j.kotlin.loggerOf + import org.ossreviewtoolkit.clients.fossid.model.rules.IgnoreRule import org.ossreviewtoolkit.clients.fossid.model.rules.RuleType import org.ossreviewtoolkit.model.Issue @@ -26,6 +30,8 @@ import org.ossreviewtoolkit.model.Severity import org.ossreviewtoolkit.model.config.Excludes import org.ossreviewtoolkit.model.config.PathExclude +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + private val DIRECTORY_REGEX = "(?.+)/(?\\*\\*)?".toRegex() private val EXTENSION_REGEX = "\\*\\.(?\\w+)".toRegex() private val FILE_REGEX = "(?[^/]+)".toRegex() @@ -43,7 +49,8 @@ internal fun convertRules(excludes: Excludes, issues: MutableList): List< message = "Path exclude '${it.pattern}' cannot be converted to an ignore rule.", severity = Severity.HINT ) - FossId.logger.warn { + + logger.warn { "Path exclude '${it.pattern}' cannot be converted to an ignore rule." } } diff --git a/plugins/scanners/licensee/src/main/kotlin/Licensee.kt b/plugins/scanners/licensee/src/main/kotlin/Licensee.kt index 9ef6cfbb03b07..c0d0483a87d09 100644 --- a/plugins/scanners/licensee/src/main/kotlin/Licensee.kt +++ b/plugins/scanners/licensee/src/main/kotlin/Licensee.kt @@ -25,7 +25,7 @@ import java.time.Instant import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonNamingStrategy -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Issue import org.ossreviewtoolkit.model.LicenseFinding @@ -46,7 +46,7 @@ private val JSON = Json { } class Licensee internal constructor(name: String, private val options: Options) : CommandLinePathScannerWrapper(name) { - companion object : Logging { + companion object { val CONFIGURATION_OPTIONS = listOf("--json") } diff --git a/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt b/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt index a69ac7ee9214b..78752e3e1b36d 100644 --- a/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt +++ b/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt @@ -24,7 +24,7 @@ import java.time.Instant import kotlin.math.max -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.ScanSummary import org.ossreviewtoolkit.model.ScannerDetails @@ -58,7 +58,7 @@ import org.semver4j.Semver * considered in [configuration], like "--processes". Defaults to [DEFAULT_NON_CONFIGURATION_OPTIONS]. */ class ScanCode internal constructor(name: String, private val options: Options) : CommandLinePathScannerWrapper(name) { - companion object : Logging { + companion object { const val SCANNER_NAME = "ScanCode" private const val LICENSE_REFERENCES_OPTION_VERSION = "32.0.0" diff --git a/plugins/scanners/scanoss/src/main/kotlin/ScanOss.kt b/plugins/scanners/scanoss/src/main/kotlin/ScanOss.kt index 88cd2d5962384..4707c4cc662c3 100644 --- a/plugins/scanners/scanoss/src/main/kotlin/ScanOss.kt +++ b/plugins/scanners/scanoss/src/main/kotlin/ScanOss.kt @@ -34,7 +34,7 @@ import okhttp3.MediaType.Companion.toMediaType import okhttp3.MultipartBody import okhttp3.RequestBody.Companion.toRequestBody -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.scanoss.ScanOssService import org.ossreviewtoolkit.model.ScanSummary @@ -50,8 +50,6 @@ private const val FAKE_WFP_FILE_NAME = "fake.wfp" private const val ARG_FIELD_NAME = "file" class ScanOss internal constructor(override val name: String, private val options: Options) : PathScannerWrapper { - private companion object : Logging - class Factory : ScannerWrapperFactory("SCANOSS") { override fun create(options: Options) = ScanOss(type, options) } diff --git a/scanner/src/main/kotlin/CommandLinePathScannerWrapper.kt b/scanner/src/main/kotlin/CommandLinePathScannerWrapper.kt index 0eea35199b4c3..bf6406f6ca827 100644 --- a/scanner/src/main/kotlin/CommandLinePathScannerWrapper.kt +++ b/scanner/src/main/kotlin/CommandLinePathScannerWrapper.kt @@ -22,8 +22,6 @@ package org.ossreviewtoolkit.scanner import java.io.File import java.time.Instant -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.model.ScanSummary import org.ossreviewtoolkit.utils.common.CommandLineTool @@ -31,8 +29,6 @@ import org.ossreviewtoolkit.utils.common.CommandLineTool * A [PathScannerWrapper] that is executed as a [CommandLineTool] on the local machine. */ abstract class CommandLinePathScannerWrapper(override val name: String) : PathScannerWrapper, CommandLineTool { - private companion object : Logging - override val version by lazy { getVersion() } final override fun scanPath(path: File, context: ScanContext): ScanSummary { diff --git a/scanner/src/main/kotlin/ScanResultsStorage.kt b/scanner/src/main/kotlin/ScanResultsStorage.kt index 97beb4c5690b5..4d0de0332140b 100644 --- a/scanner/src/main/kotlin/ScanResultsStorage.kt +++ b/scanner/src/main/kotlin/ScanResultsStorage.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.Package @@ -42,7 +42,7 @@ abstract class ScanResultsStorage : PackageBasedScanStorage { /** * A companion object that allow to configure the globally used storage backend. */ - companion object : Logging { + companion object { /** * A successful [Result] with an empty list of [ScanResult]s. */ diff --git a/scanner/src/main/kotlin/Scanner.kt b/scanner/src/main/kotlin/Scanner.kt index 9ab78099ab602..3a84e359716e9 100644 --- a/scanner/src/main/kotlin/Scanner.kt +++ b/scanner/src/main/kotlin/Scanner.kt @@ -31,7 +31,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.withContext -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.downloader.DownloadException import org.ossreviewtoolkit.model.FileList @@ -86,8 +86,6 @@ class Scanner( private val archiver: FileArchiver? = scannerConfig.archive.createFileArchiver(), fileListStorage: ProvenanceFileStorage = scannerConfig.fileListStorage.createStorage() ) { - private companion object : Logging - init { require(scannerWrappers.isNotEmpty() && scannerWrappers.any { it.value.isNotEmpty() }) { "At least one ScannerWrapper must be provided." diff --git a/scanner/src/main/kotlin/provenance/FileBasedNestedProvenanceStorage.kt b/scanner/src/main/kotlin/provenance/FileBasedNestedProvenanceStorage.kt index 0cac16ea543b2..c4da84accee63 100644 --- a/scanner/src/main/kotlin/provenance/FileBasedNestedProvenanceStorage.kt +++ b/scanner/src/main/kotlin/provenance/FileBasedNestedProvenanceStorage.kt @@ -25,7 +25,7 @@ import java.io.ByteArrayInputStream import java.io.FileNotFoundException import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.RepositoryProvenance import org.ossreviewtoolkit.model.yamlMapper @@ -35,8 +35,6 @@ import org.ossreviewtoolkit.utils.ort.showStackTrace import org.ossreviewtoolkit.utils.ort.storage.FileStorage class FileBasedNestedProvenanceStorage(private val backend: FileStorage) : NestedProvenanceStorage { - private companion object : Logging - override fun readNestedProvenance(root: RepositoryProvenance): NestedProvenanceResolutionResult? = readResults(root).find { it.nestedProvenance.root == root } diff --git a/scanner/src/main/kotlin/provenance/FileBasedPackageProvenanceStorage.kt b/scanner/src/main/kotlin/provenance/FileBasedPackageProvenanceStorage.kt index 2a420af8feea9..522df89cebed1 100644 --- a/scanner/src/main/kotlin/provenance/FileBasedPackageProvenanceStorage.kt +++ b/scanner/src/main/kotlin/provenance/FileBasedPackageProvenanceStorage.kt @@ -26,7 +26,7 @@ import java.io.ByteArrayInputStream import java.io.FileNotFoundException import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.RemoteArtifact @@ -37,8 +37,6 @@ import org.ossreviewtoolkit.utils.ort.showStackTrace import org.ossreviewtoolkit.utils.ort.storage.FileStorage class FileBasedPackageProvenanceStorage(val backend: FileStorage) : PackageProvenanceStorage { - private companion object : Logging - override fun readProvenance(id: Identifier, sourceArtifact: RemoteArtifact): PackageProvenanceResolutionResult? = readResults(id).find { it.sourceArtifact == sourceArtifact }?.result diff --git a/scanner/src/main/kotlin/provenance/NestedProvenanceResolver.kt b/scanner/src/main/kotlin/provenance/NestedProvenanceResolver.kt index 1dd48236b8744..31c1c5774f5c9 100644 --- a/scanner/src/main/kotlin/provenance/NestedProvenanceResolver.kt +++ b/scanner/src/main/kotlin/provenance/NestedProvenanceResolver.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.scanner.provenance import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.ArtifactProvenance import org.ossreviewtoolkit.model.KnownProvenance @@ -48,8 +48,6 @@ class DefaultNestedProvenanceResolver( private val storage: NestedProvenanceStorage, private val workingTreeCache: WorkingTreeCache ) : NestedProvenanceResolver { - private companion object : Logging - override fun resolveNestedProvenance(provenance: KnownProvenance): NestedProvenance { return when (provenance) { is ArtifactProvenance -> NestedProvenance(root = provenance, subRepositories = emptyMap()) diff --git a/scanner/src/main/kotlin/provenance/PackageProvenanceResolver.kt b/scanner/src/main/kotlin/provenance/PackageProvenanceResolver.kt index c67fc67e50b77..818aa276351dc 100644 --- a/scanner/src/main/kotlin/provenance/PackageProvenanceResolver.kt +++ b/scanner/src/main/kotlin/provenance/PackageProvenanceResolver.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.runBlocking import okhttp3.Request -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.ArtifactProvenance import org.ossreviewtoolkit.model.KnownProvenance @@ -61,8 +61,6 @@ class DefaultPackageProvenanceResolver( private val storage: PackageProvenanceStorage, private val workingTreeCache: WorkingTreeCache ) : PackageProvenanceResolver { - private companion object : Logging - /** * Resolve the [Provenance] of [pkg] based on the provided [sourceCodeOriginPriority]. For source artifacts it is * verified that the [RemoteArtifact] does exist. For a VCS it is verified that the revision exists. If the revision diff --git a/scanner/src/main/kotlin/storages/ClearlyDefinedStorage.kt b/scanner/src/main/kotlin/storages/ClearlyDefinedStorage.kt index bb6b228d00654..229bf72e33e97 100644 --- a/scanner/src/main/kotlin/storages/ClearlyDefinedStorage.kt +++ b/scanner/src/main/kotlin/storages/ClearlyDefinedStorage.kt @@ -28,7 +28,7 @@ import kotlinx.coroutines.runBlocking import okhttp3.OkHttpClient -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.clients.clearlydefined.ClearlyDefinedService import org.ossreviewtoolkit.clients.clearlydefined.ComponentType @@ -74,8 +74,6 @@ class ClearlyDefinedStorage( config: ClearlyDefinedStorageConfiguration, client: OkHttpClient? = null ) : ScanResultsStorage() { - private companion object : Logging - constructor(serverUrl: String, client: OkHttpClient? = null) : this( ClearlyDefinedStorageConfiguration(serverUrl), client ) diff --git a/scanner/src/main/kotlin/storages/FileBasedStorage.kt b/scanner/src/main/kotlin/storages/FileBasedStorage.kt index f817d3cf7038c..ae17b6e582199 100644 --- a/scanner/src/main/kotlin/storages/FileBasedStorage.kt +++ b/scanner/src/main/kotlin/storages/FileBasedStorage.kt @@ -25,7 +25,7 @@ import java.io.ByteArrayInputStream import java.io.FileNotFoundException import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.Package @@ -48,8 +48,6 @@ class FileBasedStorage( */ val backend: FileStorage ) : ScanResultsStorage() { - private companion object : Logging - override val name = "${javaClass.simpleName} with ${backend.javaClass.simpleName} backend" override fun readInternal(pkg: Package): Result> { diff --git a/scanner/src/main/kotlin/storages/PostgresStorage.kt b/scanner/src/main/kotlin/storages/PostgresStorage.kt index 2d6eec149fa32..b3014206c04f3 100644 --- a/scanner/src/main/kotlin/storages/PostgresStorage.kt +++ b/scanner/src/main/kotlin/storages/PostgresStorage.kt @@ -30,7 +30,7 @@ import kotlin.math.max import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.DatabaseConfig @@ -73,7 +73,7 @@ class PostgresStorage( */ private val parallelTransactions: Int ) : ScanResultsStorage() { - companion object : Logging { + companion object { /** Expression to reference the scanner version as an array. */ private const val VERSION_ARRAY = "string_to_array(regexp_replace(scan_result->'scanner'->>'version', '[^0-9.]', '', 'g'), '.')" diff --git a/scanner/src/main/kotlin/storages/ProvenanceBasedFileStorage.kt b/scanner/src/main/kotlin/storages/ProvenanceBasedFileStorage.kt index e738c194fe8a5..ba44f33d3450f 100644 --- a/scanner/src/main/kotlin/storages/ProvenanceBasedFileStorage.kt +++ b/scanner/src/main/kotlin/storages/ProvenanceBasedFileStorage.kt @@ -25,7 +25,7 @@ import java.io.ByteArrayInputStream import java.io.FileNotFoundException import java.io.IOException -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.model.ArtifactProvenance import org.ossreviewtoolkit.model.KnownProvenance @@ -41,8 +41,6 @@ import org.ossreviewtoolkit.utils.ort.showStackTrace import org.ossreviewtoolkit.utils.ort.storage.FileStorage class ProvenanceBasedFileStorage(private val backend: FileStorage) : ProvenanceBasedScanStorage { - private companion object : Logging - override fun read(provenance: KnownProvenance): List { requireEmptyVcsPath(provenance) diff --git a/scanner/src/main/kotlin/storages/ProvenanceBasedPostgresStorage.kt b/scanner/src/main/kotlin/storages/ProvenanceBasedPostgresStorage.kt index b02c30b8f2e3e..5d23124a24dab 100644 --- a/scanner/src/main/kotlin/storages/ProvenanceBasedPostgresStorage.kt +++ b/scanner/src/main/kotlin/storages/ProvenanceBasedPostgresStorage.kt @@ -23,7 +23,7 @@ import java.sql.SQLException import javax.sql.DataSource -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.Database @@ -61,8 +61,6 @@ class ProvenanceBasedPostgresStorage( */ private val tableName: String = "provenance_scan_results" ) : ProvenanceBasedScanStorage { - private companion object : Logging - private val table = ProvenanceScanResults(tableName) /** The [Database] instance on which all operations are executed. */ diff --git a/scanner/src/main/kotlin/storages/Sw360Storage.kt b/scanner/src/main/kotlin/storages/Sw360Storage.kt index 338cef50ccb96..68338f8066334 100644 --- a/scanner/src/main/kotlin/storages/Sw360Storage.kt +++ b/scanner/src/main/kotlin/storages/Sw360Storage.kt @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import java.nio.file.Path -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.eclipse.sw360.clients.adapter.AttachmentUploadRequest import org.eclipse.sw360.clients.adapter.SW360Connection @@ -56,7 +56,7 @@ import org.ossreviewtoolkit.utils.ort.createOrtTempDir class Sw360Storage( configuration: Sw360StorageConfiguration ) : ScanResultsStorage() { - companion object : Logging { + companion object { val JSON_MAPPER: ObjectMapper = jsonMapper.copy() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) diff --git a/utils/common/src/main/kotlin/ArchiveUtils.kt b/utils/common/src/main/kotlin/ArchiveUtils.kt index 10f63c135c5b7..b5635602894d8 100644 --- a/utils/common/src/main/kotlin/ArchiveUtils.kt +++ b/utils/common/src/main/kotlin/ArchiveUtils.kt @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -@file:Suppress("TooManyFunctions") +@file:Suppress("MatchingDeclarationName", "TooManyFunctions") package org.ossreviewtoolkit.utils.common @@ -45,9 +45,7 @@ import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream import org.apache.commons.compress.compressors.xz.XZCompressorInputStream import org.apache.commons.compress.utils.SeekableInMemoryByteChannel -import org.apache.logging.log4j.kotlin.Logging - -object ArchiveUtils : Logging +import org.apache.logging.log4j.kotlin.logger enum class ArchiveType(extension: String, vararg aliases: String) { SEVENZIP(".7z"), @@ -114,7 +112,7 @@ fun File.unpackTryAllTypes(targetDirectory: File, filter: (ArchiveEntry) -> Bool runCatching { unpack(targetDirectory, forceArchiveType = archiveType, filter) }.onSuccess { - ArchiveUtils.logger.debug { "Unpacked stream as $archiveType to '$targetDirectory'." } + logger.debug { "Unpacked stream as $archiveType to '$targetDirectory'." } }.onFailure { suppressedExceptions += IOException("Unpacking '$this' as $archiveType failed.", it) }.isSuccess @@ -142,7 +140,7 @@ fun File.unpack7Zip(targetDirectory: File, filter: (ArchiveEntry) -> Boolean = { val target = targetDirectory.resolve(entry.name) if (!target.canonicalFile.startsWith(canonicalTargetDirectory)) { - ArchiveUtils.logger.warn { + logger.warn { "Skipping entry '${entry.name}' which points to outside of '$targetDirectory'." } @@ -192,7 +190,7 @@ private fun ZipFile.unpack(targetDirectory: File, filter: (ArchiveEntry) -> Bool val target = targetDirectory.resolve(entry.name) if (!target.canonicalFile.startsWith(canonicalTargetDirectory)) { - ArchiveUtils.logger.warn { + logger.warn { "Skipping entry '${entry.name}' which points to outside of '$targetDirectory'." } @@ -285,7 +283,7 @@ private fun ArchiveInputStream.unpack( val target = targetDirectory.resolve(entry.name) if (!target.canonicalFile.startsWith(canonicalTargetDirectory)) { - ArchiveUtils.logger.warn { + logger.warn { "Skipping entry '${entry.name}' which points to outside of '$targetDirectory'." } diff --git a/utils/common/src/main/kotlin/CommandLineTool.kt b/utils/common/src/main/kotlin/CommandLineTool.kt index b4965c4bb601c..dd3746d40da3f 100644 --- a/utils/common/src/main/kotlin/CommandLineTool.kt +++ b/utils/common/src/main/kotlin/CommandLineTool.kt @@ -21,7 +21,7 @@ package org.ossreviewtoolkit.utils.common import java.io.File -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.semver4j.RangesList import org.semver4j.RangesListFactory @@ -31,7 +31,7 @@ import org.semver4j.Semver * An interface to implement by classes that are backed by a command line tool. */ interface CommandLineTool { - companion object : Logging { + companion object { /** * A convenience property to require any version. */ diff --git a/utils/common/src/main/kotlin/DirectoryStash.kt b/utils/common/src/main/kotlin/DirectoryStash.kt index 2bec409a110bd..f1cf45597bd75 100644 --- a/utils/common/src/main/kotlin/DirectoryStash.kt +++ b/utils/common/src/main/kotlin/DirectoryStash.kt @@ -29,7 +29,7 @@ import java.nio.file.StandardCopyOption import kotlin.io.path.createTempDirectory import kotlin.io.path.moveTo -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * A convenience function that stashes directories using a [DirectoryStash] instance. @@ -42,8 +42,6 @@ fun stashDirectories(vararg directories: File): Closeable = DirectoryStash(setOf * directory did not exist on initialization, it will also not exist on close. */ private class DirectoryStash(directories: Set) : Closeable { - private companion object : Logging - private val stashedDirectories: Map = directories.associateWith { originalDir -> // We need to check this on each iteration instead of filtering beforehand to properly handle parent / child // directories. diff --git a/utils/common/src/main/kotlin/DiskCache.kt b/utils/common/src/main/kotlin/DiskCache.kt index ec9764aa95e0b..c08825d1cf71f 100644 --- a/utils/common/src/main/kotlin/DiskCache.kt +++ b/utils/common/src/main/kotlin/DiskCache.kt @@ -26,7 +26,7 @@ import java.io.IOException import kotlin.math.pow -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * Wrapper around [DiskLruCache] that adds a workaround for the 64 character key length limit. @@ -47,7 +47,7 @@ class DiskCache( */ private val maxCacheEntryAgeInSeconds: Long ) { - companion object : Logging { + companion object { const val INDEX_FULL_KEY = 0 const val INDEX_TIMESTAMP = 1 const val INDEX_DATA = 2 diff --git a/utils/common/src/main/kotlin/EnvironmentVariableFilter.kt b/utils/common/src/main/kotlin/EnvironmentVariableFilter.kt index b62905905c794..bb270d25a903d 100644 --- a/utils/common/src/main/kotlin/EnvironmentVariableFilter.kt +++ b/utils/common/src/main/kotlin/EnvironmentVariableFilter.kt @@ -19,7 +19,7 @@ package org.ossreviewtoolkit.utils.common -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * An object providing functionality to filter environments that are passed to newly created processes. @@ -43,7 +43,7 @@ import org.apache.logging.log4j.kotlin.Logging * TODO: Find an alternative mechanism to initialize this object from the ORT configuration (maybe using dependency * injection) which does not require this object to be public. */ -object EnvironmentVariableFilter : Logging { +object EnvironmentVariableFilter { /** * A set with substrings contained in variable names that are denied by default. All variables containing one of * these strings (ignoring case) are not propagated to child processes. diff --git a/utils/common/src/main/kotlin/ProcessCapture.kt b/utils/common/src/main/kotlin/ProcessCapture.kt index ad5bebc856428..3e602fa0e445a 100644 --- a/utils/common/src/main/kotlin/ProcessCapture.kt +++ b/utils/common/src/main/kotlin/ProcessCapture.kt @@ -24,7 +24,7 @@ import java.io.IOException import kotlin.io.path.createTempDirectory -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * An (almost) drop-in replacement for ProcessBuilder that is able to capture huge outputs to the standard output and @@ -40,7 +40,7 @@ class ProcessCapture( // vararg parameters, see https://stackoverflow.com/a/46456379/1127485. constructor(workingDir: File?, vararg command: CharSequence) : this(*command, workingDir = workingDir) - companion object : Logging { + companion object { private const val MAX_OUTPUT_LINES = 20 private const val MAX_OUTPUT_FOOTER = "(Above output is limited to each $MAX_OUTPUT_LINES heading and tailing lines.)" diff --git a/utils/ort/src/funTest/kotlin/storage/HttpFileStorageFunTest.kt b/utils/ort/src/funTest/kotlin/storage/HttpFileStorageFunTest.kt index 6074eb06a755a..0564214d2cfd6 100644 --- a/utils/ort/src/funTest/kotlin/storage/HttpFileStorageFunTest.kt +++ b/utils/ort/src/funTest/kotlin/storage/HttpFileStorageFunTest.kt @@ -37,11 +37,9 @@ import java.net.InetSocketAddress import kotlin.random.Random -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger class HttpFileStorageFunTest : WordSpec() { - private companion object : Logging - private val loopback = InetAddress.getLoopbackAddress() private val port = Random.nextInt(1024, 49152) // See https://en.wikipedia.org/wiki/Registered_port. .also { logger.debug { "Using port $it for HTTP server." } } diff --git a/utils/ort/src/main/kotlin/DeclaredLicenseProcessor.kt b/utils/ort/src/main/kotlin/DeclaredLicenseProcessor.kt index f57bfcff6c75c..bcbba8a6e0097 100644 --- a/utils/ort/src/main/kotlin/DeclaredLicenseProcessor.kt +++ b/utils/ort/src/main/kotlin/DeclaredLicenseProcessor.kt @@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.annotation.JsonPropertyOrder import com.fasterxml.jackson.databind.annotation.JsonSerialize -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.utils.common.StringSortedSetConverter import org.ossreviewtoolkit.utils.common.collectMessages @@ -36,7 +36,7 @@ import org.ossreviewtoolkit.utils.spdx.SpdxExpression import org.ossreviewtoolkit.utils.spdx.SpdxOperator import org.ossreviewtoolkit.utils.spdx.toSpdx -object DeclaredLicenseProcessor : Logging { +object DeclaredLicenseProcessor { private val urlPrefixesToRemove = listOf( "choosealicense.com/licenses/", "gnu.org/licenses/old-licenses/", diff --git a/utils/ort/src/main/kotlin/NetRcAuthenticator.kt b/utils/ort/src/main/kotlin/NetRcAuthenticator.kt index f24b53ca33728..a525669b3181a 100644 --- a/utils/ort/src/main/kotlin/NetRcAuthenticator.kt +++ b/utils/ort/src/main/kotlin/NetRcAuthenticator.kt @@ -19,10 +19,12 @@ package org.ossreviewtoolkit.utils.ort +import java.lang.invoke.MethodHandles import java.net.Authenticator import java.net.PasswordAuthentication -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger +import org.apache.logging.log4j.kotlin.loggerOf import org.ossreviewtoolkit.utils.common.Os import org.ossreviewtoolkit.utils.common.nextOrNull @@ -31,8 +33,6 @@ import org.ossreviewtoolkit.utils.common.nextOrNull * A simple non-caching authenticator that reads credentials from .netrc-style files. */ class NetRcAuthenticator : Authenticator() { - internal companion object : Logging - // TODO: Add support for ".authinfo" files (which use the same syntax as .netrc files) once Git.kt does not call the // Git CLI anymore which only supports ".netrc" (and "_netrc") files. private val netrcFileNames = listOf(".netrc", "_netrc") @@ -54,6 +54,8 @@ class NetRcAuthenticator : Authenticator() { } } +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + /** * Parse the [contents] of a [.netrc](https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html) * file for a login / password matching [machine]. @@ -78,7 +80,7 @@ internal fun getNetrcAuthentication(contents: String, machine: String): Password } if (login != null && password != null) { - NetRcAuthenticator.logger.debug { "Found a '$machineFound' entry for '$machine'." } + logger.debug { "Found a '$machineFound' entry for '$machine'." } return PasswordAuthentication(login, password.toCharArray()) } } diff --git a/utils/ort/src/main/kotlin/OkHttpClientHelper.kt b/utils/ort/src/main/kotlin/OkHttpClientHelper.kt index db0e700968266..3386ea91b42f3 100644 --- a/utils/ort/src/main/kotlin/OkHttpClientHelper.kt +++ b/utils/ort/src/main/kotlin/OkHttpClientHelper.kt @@ -21,6 +21,7 @@ package org.ossreviewtoolkit.utils.ort import java.io.File import java.io.IOException +import java.lang.invoke.MethodHandles import java.time.Duration import java.util.concurrent.ConcurrentHashMap @@ -43,7 +44,8 @@ import okhttp3.ResponseBody import okio.buffer import okio.sink -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger +import org.apache.logging.log4j.kotlin.loggerOf import org.ossreviewtoolkit.utils.common.ArchiveType import org.ossreviewtoolkit.utils.common.collectMessages @@ -61,7 +63,7 @@ class HttpDownloadError(val code: Int, message: String) : IOException("$message /** * A helper class to manage OkHttp instances backed by distinct cache directories. */ -object OkHttpClientHelper : Logging { +object OkHttpClientHelper { /** * A constant for the "too many requests" HTTP code as HttpURLConnection has none. */ @@ -79,6 +81,8 @@ object OkHttpClientHelper : Logging { } ?: okHttpClient } +private val logger = loggerOf(MethodHandles.lookup().lookupClass()) + private const val CACHE_DIRECTORY = "cache/http" private val MAX_CACHE_SIZE_IN_BYTES = 1.gibibytes private const val READ_TIMEOUT_IN_SECONDS = 30L @@ -110,7 +114,7 @@ val okHttpClient: OkHttpClient by lazy { }.onFailure { it.showStackTrace() - OkHttpClientHelper.logger.error { + logger.error { "HTTP request to '${request.url}' failed with an exception: ${it.collectMessages()}" } }.getOrThrow() @@ -230,7 +234,7 @@ fun OkHttpClient.ping(url: String): Response = */ fun OkHttpClient.execute(request: Request): Response = newCall(request).execute().also { response -> - OkHttpClientHelper.logger.debug { + logger.debug { if (response.cacheResponse != null) { "Retrieved ${response.request.url} from local cache." } else { diff --git a/utils/ort/src/main/kotlin/OrtAuthenticator.kt b/utils/ort/src/main/kotlin/OrtAuthenticator.kt index 566006b0dc7e6..3ae55a3200c9b 100644 --- a/utils/ort/src/main/kotlin/OrtAuthenticator.kt +++ b/utils/ort/src/main/kotlin/OrtAuthenticator.kt @@ -26,14 +26,14 @@ import java.net.Proxy import java.net.ProxySelector import java.util.concurrent.ConcurrentHashMap -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * A caching authenticator that chains other authenticators. For proxy authentication, the [OrtProxySelector] is * required to also be installed. */ class OrtAuthenticator(private val original: Authenticator? = null) : Authenticator() { - companion object : Logging { + companion object { /** * Install this authenticator as the global default. */ diff --git a/utils/ort/src/main/kotlin/OrtProxySelector.kt b/utils/ort/src/main/kotlin/OrtProxySelector.kt index adde9157c06b7..e949bcc32d5d4 100644 --- a/utils/ort/src/main/kotlin/OrtProxySelector.kt +++ b/utils/ort/src/main/kotlin/OrtProxySelector.kt @@ -27,7 +27,7 @@ import java.net.ProxySelector import java.net.SocketAddress import java.net.URI -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.utils.common.Os @@ -40,7 +40,7 @@ const val DEFAULT_PROXY_PORT = 8080 * A proxy selector which supports dynamic addition and removal of proxies with optional password authentication. */ class OrtProxySelector(private val fallback: ProxySelector? = null) : ProxySelector() { - companion object : Logging { + companion object { internal val NO_PROXY_LIST = listOf(Proxy.NO_PROXY) /** diff --git a/utils/ort/src/main/kotlin/storage/HttpFileStorage.kt b/utils/ort/src/main/kotlin/storage/HttpFileStorage.kt index 8d8d53a207d73..91e6346b2508f 100644 --- a/utils/ort/src/main/kotlin/storage/HttpFileStorage.kt +++ b/utils/ort/src/main/kotlin/storage/HttpFileStorage.kt @@ -30,7 +30,7 @@ import okhttp3.Headers.Companion.toHeaders import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger import org.ossreviewtoolkit.utils.ort.OkHttpClientHelper import org.ossreviewtoolkit.utils.ort.execute @@ -67,8 +67,6 @@ class HttpFileStorage( */ private val cacheMaxAgeInSeconds: Int = 0 ) : FileStorage { - private companion object : Logging - private val httpClient by lazy { OkHttpClientHelper.buildClient { val connectionPool = ConnectionPool( diff --git a/utils/ort/src/main/kotlin/storage/LocalFileStorage.kt b/utils/ort/src/main/kotlin/storage/LocalFileStorage.kt index dbc0072f6e441..b6c0c307e7f59 100644 --- a/utils/ort/src/main/kotlin/storage/LocalFileStorage.kt +++ b/utils/ort/src/main/kotlin/storage/LocalFileStorage.kt @@ -23,8 +23,6 @@ import java.io.File import java.io.InputStream import java.io.OutputStream -import org.apache.logging.log4j.kotlin.Logging - import org.ossreviewtoolkit.utils.common.safeMkdirs /** @@ -37,8 +35,6 @@ open class LocalFileStorage( */ val directory: File ) : FileStorage { - private companion object : Logging - /** * Return the internally used path, which might differ from the provided [path] e.g. in case a suffix is added to * denote a compression scheme. diff --git a/utils/scripting/src/main/kotlin/ScriptRunner.kt b/utils/scripting/src/main/kotlin/ScriptRunner.kt index b8b27905b28db..1d80fe664fd95 100644 --- a/utils/scripting/src/main/kotlin/ScriptRunner.kt +++ b/utils/scripting/src/main/kotlin/ScriptRunner.kt @@ -31,14 +31,12 @@ import kotlin.time.measureTimedValue import kotlinx.coroutines.runBlocking -import org.apache.logging.log4j.kotlin.Logging +import org.apache.logging.log4j.kotlin.logger /** * A class providing the framework to run Kotlin scripts. */ abstract class ScriptRunner { - private companion object : Logging - /** The scripting host instance. */ private val scriptingHost = BasicJvmScriptingHost() From 8b79956aa30b6fa08f96b3c297a64d3a22908756 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 6 Oct 2023 19:30:35 +0200 Subject: [PATCH 3/5] docs(MavenLogger): Correct a comment about the logger forwarded to Signed-off-by: Sebastian Schuberth --- analyzer/src/main/kotlin/managers/utils/MavenLogger.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt b/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt index 94b2773317b0e..780640a829f51 100644 --- a/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt +++ b/analyzer/src/main/kotlin/managers/utils/MavenLogger.kt @@ -41,8 +41,8 @@ private fun toPlexusLoggerLevel(level: Level) = } /** - * Implementation of the Plexus [Logger] that forwards all logs to [org.apache.logging.log4j.kotlin.Logging] using the - * appropriate log levels. + * Implementation of the Plexus [Logger] that forwards all logs to [org.apache.logging.log4j.kotlin.KotlinLogger] using + * the appropriate log levels. */ class MavenLogger(level: Level) : AbstractLogger(toPlexusLoggerLevel(level), "MavenLogger") { override fun getChildLogger(name: String?) = this From 0f01456d12ba3ad6b7223db7ff19f4c7b7356c01 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 6 Oct 2023 22:24:17 +0200 Subject: [PATCH 4/5] chore(GitLabLicenseModelMapper): Slightly improve a log message Signed-off-by: Sebastian Schuberth --- .../gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt b/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt index a6434c029f65a..b4887adab0192 100644 --- a/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt +++ b/plugins/reporters/gitlab/src/main/kotlin/GitLabLicenseModelMapper.kt @@ -120,6 +120,6 @@ private fun Identifier.toPackageManagerName(): String = "PIP" -> "pip" "Yarn" -> "yarn" else -> type.lowercase().also { - logger.info { "No mapping defined for package manager '$type', guessing '$it'." } + logger.info { "No GitLab mapping defined for package manager '$type', guessing '$it'." } } } From e40b8ed326a1fe7ec8fccf72104fac1c1e994f64 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 6 Oct 2023 22:27:23 +0200 Subject: [PATCH 5/5] chore: Make `OkHttpClientHelper` the first class in the file `OkHttpClientHelper` should go first as the file is named after it. Signed-off-by: Sebastian Schuberth --- utils/ort/src/main/kotlin/OkHttpClientHelper.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/ort/src/main/kotlin/OkHttpClientHelper.kt b/utils/ort/src/main/kotlin/OkHttpClientHelper.kt index 3386ea91b42f3..c6e16ec7a53da 100644 --- a/utils/ort/src/main/kotlin/OkHttpClientHelper.kt +++ b/utils/ort/src/main/kotlin/OkHttpClientHelper.kt @@ -55,11 +55,6 @@ import org.ossreviewtoolkit.utils.common.withoutPrefix typealias BuilderConfiguration = OkHttpClient.Builder.() -> Unit -/** - * An HTTP-specific download error that enriches an [IOException] with an additional HTTP error code. - */ -class HttpDownloadError(val code: Int, message: String) : IOException("$message (HTTP code $code)") - /** * A helper class to manage OkHttp instances backed by distinct cache directories. */ @@ -81,6 +76,11 @@ object OkHttpClientHelper { } ?: okHttpClient } +/** + * An HTTP-specific download error that enriches an [IOException] with an additional HTTP error code. + */ +class HttpDownloadError(val code: Int, message: String) : IOException("$message (HTTP code $code)") + private val logger = loggerOf(MethodHandles.lookup().lookupClass()) private const val CACHE_DIRECTORY = "cache/http"