Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lower the logging level from info to debug #167

Open
wants to merge 2 commits into
base: merge/v0.9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java-agent/drill.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logLevel=INFO;com.epam.drill=TRACE;com.epam.drill.shadow=INFO;com.epam.drill.test2code.classloading=DEBUG
logLevel=INFO
11 changes: 5 additions & 6 deletions java-agent/src/nativeMain/kotlin/com/epam/drill/agent/Agent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ object Agent {
U| |_| |\| _ < | | \| |/__ \| |/__ |__ _| | |_| |_,-.
|____/ u|_| \_\ U/| |\u |_____| |_____| /|_|\ \___/-(_/
|||_ // \\_.-,_|___|_,-.// \\ // \\ u_|||_u _//
(__)_) (__) (__)\_)-' '-(_/(_")("_)(_")("_) (__)__) (__) v. ${agentVersion}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
(__)_) (__) (__)\_)-' '-(_/(_")("_)(_")("_) (__)__) (__)
Java Agent (v${agentVersion})
""".trimIndent()

private val logger = KotlinLogging.logger("com.epam.drill.agent.Agent")

fun agentOnLoad(options: String): Int {
println(logo)

AgentLoggingConfiguration.defaultNativeLoggingConfiguration()
Configuration.initializeNative(options)
AgentLoggingConfiguration.updateNativeLoggingConfiguration()
Expand All @@ -63,14 +63,13 @@ object Agent {
setUnhandledExceptionHook({ error: Throwable -> logger.error(error) { "Unhandled event: $error" }}.freeze())
AddToBootstrapClassLoaderSearch("${Configuration.parameters[INSTALLATION_DIR]}/drill-runtime.jar")

logger.info { "agentOnLoad: The native agent has been loaded" }
logger.info { "agentOnLoad: Pid is: " + getpid() }
logger.info { "agentOnLoad: Java Agent has been loaded. Pid is: " + getpid() }

return JNI_OK
}

fun agentOnUnload() {
logger.info { "agentOnUnload" }
logger.info { "agentOnUnload: Java Agent has been unloaded." }
}

fun agentOnVmInit() {
Expand All @@ -89,7 +88,7 @@ object Agent {
}

fun agentOnVmDeath() {
logger.info { "agentOnVmDeath" }
logger.debug { "agentOnVmDeath" }
}

private fun addCapabilities() = memScoped {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ actual object Configuration : AgentConfiguration {

actual fun initializeNative(agentOptions: String) {
val environmentVariablesProvider = EnvironmentVariablesProvider()
logger.info { "initializeNative: Found environment variables: ${environmentVariablesProvider.configuration}" }
logger.debug { "initializeNative: Found environment variables: ${environmentVariablesProvider.configuration}" }
val agentOptionsProvider = AgentOptionsProvider(agentOptions)
logger.info { "initializeNative: Found agent options: ${agentOptionsProvider.configuration}" }
logger.debug { "initializeNative: Found agent options: ${agentOptionsProvider.configuration}" }
val installationDirProvider = InstallationDirProvider(setOf(
environmentVariablesProvider,
agentOptionsProvider
))
logger.info { "initializeNative: Found installation dir: ${installationDirProvider.configuration}" }
logger.debug { "initializeNative: Found installation dir: ${installationDirProvider.configuration}" }
val propertiesFileProvider = PropertiesFileProvider(setOf(
environmentVariablesProvider,
agentOptionsProvider,
installationDirProvider
))
logger.info { "initializeNative: Found from properties file: ${propertiesFileProvider.configuration}" }
logger.debug { "initializeNative: Found from properties file: ${propertiesFileProvider.configuration}" }
val validatedParametersProvider = ValidatedParametersProvider(setOf(
environmentVariablesProvider,
agentOptionsProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ object ClassFileLoadHook {
}
// TODO Http hook does not work for Netty on linux system
if ('$' !in kClassName && kClassName.startsWith(NettyTransformer.HANDLER_CONTEXT)) {
logger.info { "Starting transform Netty class kClassName $kClassName..." }
logger.debug { "Starting transform Netty class kClassName $kClassName..." }
transformers += { bytes ->
NettyTransformer.transform(kClassName, bytes, loader, protectionDomain)
}
Expand All @@ -152,7 +152,7 @@ object ClassFileLoadHook {
}.takeIf { it !== classBytes }?.let { newBytes ->
logger.trace { "$kClassName transformed" }
totalTransformClass.addAndGet(1).takeIf { it % 100 == 0 }?.let {
logger.debug { "$it classes are transformed" }
logger.trace { "$it classes are transformed" }
}
convertToNativePointers(newBytes, newData, newClassDataLen)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Test2Code(

override fun load() {
ParametersValidator.validate(configuration.parameters)
logger.info { "load: Waiting for transport availability for class metadata scanning" }
logger.debug { "load: Waiting for transport availability for class metadata scanning" }
thread {
scanAndSendMetadataClasses()
coverageSender.startSendingCoverage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ClassLoadersScanner(
private val classPathScanner = ClassPathScanner(packagePrefixes, classesBufferSize, transfer)

private val getOrLogFail: Result<URI>.() -> URI? = {
this.onFailure { logger.error(it) { "ClassLoadersScanner: error handling classpath URI" } }
this.onFailure { logger.warn { "ClassLoadersScanner: error handling classpath URI: ${it.message}" } }
this.getOrNull()
}

Expand Down Expand Up @@ -106,7 +106,7 @@ class ClassLoadersScanner(
classloader.getResources("/").toList().let(addAsUris)
}
result.onFailure {
logger.error(it) { "ClassLoadersScanner: error retrieving classpath URIs from classloader $classloader" }
logger.warn { "ClassLoadersScanner: error retrieving classpath URIs from classloader $classloader: ${it.message}" }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ClassPathScanner(
private val scannedBuffer = mutableSetOf<ClassSource>()

private val getOrLogFail: Result<Int>.() -> Int = {
this.onFailure { logger.error(it) { "ClassPathScanner: error handling class file" } }
this.onFailure { logger.warn { "ClassPathScanner: error handling class file: ${it.message}" } }
this.getOrDefault(0)
}

Expand Down Expand Up @@ -75,7 +75,7 @@ class ClassPathScanner(
*/
private fun scanDirectory(file: File) = file.run {
val isClassFile: (File) -> Boolean = { it.isFile && it.extension == "class" }
logger.debug { "ClassPathScanner: scanning directory: ${this.absolutePath}" }
logger.debug { "scanDirectory: scanning directory: ${this.absolutePath}" }
this.walkTopDown().filter(isClassFile).sumOf { scanClassFile(it, this).getOrLogFail() }
}

Expand All @@ -90,7 +90,7 @@ class ClassPathScanner(
val fileToStream: (File) -> JarInputStream = { JarInputStream(it.inputStream().buffered(JAR_BUFFER_SIZE)) }
val pathToFile: (String) -> File? = { File(this.parent, it).takeIf(File::exists) }
var scanned = 0
logger.debug { "ClassPathScanner: scanning file: ${this.absolutePath}" }
logger.debug { "scanJarFile: scanning file: ${this.absolutePath}" }
this.takeIf(isNotScanned)?.let(fileToStream)?.use {
scanned += scanJarInputStream(it).also { scannedJarFiles.add(this.absolutePath) }
scanned += it.manifest?.mainAttributes?.getValue(Attributes.Name.CLASS_PATH)?.split(" ")
Expand Down Expand Up @@ -170,7 +170,7 @@ class ClassPathScanner(
* @return scanned classes count
*/
private fun scanJarEntry(entry: JarEntry, bytes: ByteArray): Result<Int> = entry.name.runCatching {
logger.debug { "ClassPathScanner: scanning jar entry: $this" }
logger.debug { "scanJarEntry: scanning jar entry: $this" }
JarInputStream(ByteArrayInputStream(bytes)).use(::scanJarInputStream)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class IntervalCoverageSender(
intervalMs,
TimeUnit.MILLISECONDS
)
logger.debug { "Coverage sending job is started." }
logger.info { "Coverage sending job is started." }
}

override fun stopSendingCoverage() {
scheduledThreadPool.shutdown()
logger.debug { "Coverage sending job is stopped." }
logger.info { "Coverage sending job is stopped." }
}

/**
Expand Down