{"id":15138626,"url":"https://github.com/davidafsilva/vertx-logging-interceptor","last_synced_at":"2026-01-20T02:46:51.311Z","repository":{"id":56177360,"uuid":"302866787","full_name":"davidafsilva/vertx-logging-interceptor","owner":"davidafsilva","description":"Logging Interceptor Plugin for Vert.x","archived":false,"fork":false,"pushed_at":"2021-12-23T11:12:09.000Z","size":273,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T09:19:30.922Z","etag":null,"topics":["interceptor","logging","thread-blocks","vertx"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidafsilva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-10T09:36:52.000Z","updated_at":"2021-12-23T11:12:11.000Z","dependencies_parsed_at":"2022-08-15T14:10:22.441Z","dependency_job_id":null,"html_url":"https://github.com/davidafsilva/vertx-logging-interceptor","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/davidafsilva/vertx-logging-interceptor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidafsilva%2Fvertx-logging-interceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidafsilva%2Fvertx-logging-interceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidafsilva%2Fvertx-logging-interceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidafsilva%2Fvertx-logging-interceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidafsilva","download_url":"https://codeload.github.com/davidafsilva/vertx-logging-interceptor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidafsilva%2Fvertx-logging-interceptor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28594958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interceptor","logging","thread-blocks","vertx"],"created_at":"2024-09-26T07:42:33.251Z","updated_at":"2026-01-20T02:46:51.286Z","avatar_url":"https://github.com/davidafsilva.png","language":"Kotlin","readme":"# Vertx Logging Interceptor \n\n[![Master Build Status](https://img.shields.io/github/workflow/status/davidafsilva/vertx-logging-interceptor/Master%20Build?label=Build\u0026style=flat-square)](https://github.com/davidafsilva/vertx-logging-interceptor/actions?query=workflow%3A%22Master+Build%22+branch%3Amaster)\n[![Coverage Report](https://img.shields.io/coveralls/github/davidafsilva/vertx-logging-interceptor?color=brightgreen\u0026label=Coverage\u0026style=flat-square)](https://coveralls.io/github/davidafsilva/vertx-logging-interceptor)\n[![Latest Release](https://img.shields.io/maven-central/v/pt.davidafsilva.vertx/vertx-logging-interceptor?color=brightgreen\u0026label=Latest%20Release\u0026style=flat-square)](https://repo1.maven.org/maven2/pt/davidafsilva/vertx/vertx-logging-interceptor/)\n[![License](https://img.shields.io/github/license/davidafsilva/vertx-logging-interceptor?color=brightgreen\u0026label=License\u0026logo=License\u0026style=flat-square)](https://opensource.org/licenses/BSD-3-Clause)\n\n\nThis small library plugs into Vert.x's logging delegation by leveraging its flexible configuration, allowing \nthird-party interceptors to be built and plugged into the application logging mechanism.\n\n## Table of Contents\n* [Usage](#usage)\n  + [Import](#import)\n    - [Gradle](#gradle)\n    - [Maven](#maven)\n  + [Configuration](#configuration)\n  + [Interceptor Creation](#interceptor-creation)\n    - [Blocking Interceptors](#blocking-interceptors)\n    - [Non-Blocking Interceptors](#non-blocking-interceptors)\n  + [Registering Interceptors](#registering-interceptors)\n* [Built-In Interceptors](#built-in-interceptors)\n  + [ThreadBlockedLogInterceptor](#threadblockedloginterceptor)\n* [Building](#building)\n\n## Usage\n\n### Import\n1. Add maven central repository to your configuration\n2. Import the library\n\n#### Gradle\nGroovy:\n```kotlin\nrepositories {\n    mavenCentral()\n}\ndependencies {\n    implementation(\"pt.davidafsilva.vertx:vertx-logging-interceptor:0.1.3\")\n}\n```\n\n#### Maven\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003ept.davidafsilva.vertx\u003c/groupId\u003e\n    \u003cartifactId\u003evertx-logging-interceptor\u003c/artifactId\u003e\n    \u003cversion\u003e0.1.3\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n### Configuration\nSimilarly, as Vert.x, it provides 4 possible configurations. One for each supported logging library:\n\n| Factory | Description | \n| --- | --- | \n| [VertxJULLogDelegateFactory](src/main/kotlin/pt/davidafsilva/vertx/logging/factory/VertxLogDelegateFactory.kt#L25) | Creates loggers bound to Java Util Logging | \n| [VertxLog4jLogDelegateFactory](src/main/kotlin/pt/davidafsilva/vertx/logging/factory/VertxLogDelegateFactory.kt#L27) | Creates loggers bound to Apache Log4j (v1) | \n| [VertxLog4j2LogDelegateFactory](src/main/kotlin/pt/davidafsilva/vertx/logging/factory/VertxLogDelegateFactory.kt#L26) | Creates loggers bound to Apache Log4j (v2) | \n| [VertxSLF4JLogDelegateFactory](src/main/kotlin/pt/davidafsilva/vertx/logging/factory/VertxLogDelegateFactory.kt#L28) | Creates loggers bound to the available SLF4J implementation | \n\nChoose one of the above class names (use FQN) according to your runtime logging library and configure it through the \n`vertx.logger-delegate-factory-class-name` system property. \nAlternatively, you can set it through a JVM argument:\n```\n-Dvertx.logger-delegate-factory-class-name=pt.davidafsilva.vertx.logging.factory.\u003cchosen delegate factory\u003e\n```\n\n### Interceptor Creation\nAfter configuring the appropriate logger factory, creating an interceptor can be achieved by implementing the \n[LogInterceptor](src/main/kotlin/pt/davidafsilva/vertx/logging/LogInterceptor.kt) interface along with the required\nmethods. Optionally, you can opt for [NoOpLogInterceptor](src/main/kotlin/pt/davidafsilva/vertx/logging/LogInterceptor.kt#L12)\nwhich provides an empty skeleton for all the required methods.\n\nThere are essentially two types of interceptors, blocking and non-blocking.  \nBlocking interceptors are characterized by returning [LogPropagation.BLOCK](src/main/kotlin/pt/davidafsilva/vertx/logging/LogInterceptor.kt#L26)\nas the/a possible outcome of an interception call. These interceptors, upon returning `LogPropagation.BLOCK` will \neffectively stop both the execution of any other interceptors in the chain alongside with the actual logging to the \nunderlying logger.  \nOn the other hand, non-blocking interceptors do not affect any sub-sequent operations. They always return \n[LogPropagation.CONTINUE](src/main/kotlin/pt/davidafsilva/vertx/logging/LogInterceptor.kt#L26).\n\n#### Blocking Interceptors\n```kotlin\nobject LogMessagesCounterInterceptor : NoOpLogInterceptor {\n    private val counter = AtomicLong()\n\n    override fun intercept(logger: String, message: Any?): LogPropagation {\n        counter.incrementAndGet()\n        return LogPropagation.CONTINUE\n    }\n    \n    fun totalLoggedMessages(): Long = counter.get()\n}\n```\n\n#### Non-Blocking Interceptors \n```kotlin\nobject BadWordLogInterceptor : NoOpLogInterceptor {\n    override fun intercept(logger: String, message: Any?): LogPropagation {\n        val strMessage = message.toString()\n        return when {\n            \"badword\" in strMessage -\u003e LogPropagation.BLOCK\n            else -\u003e LogPropagation.CONTINUE\n        }\n    }\n}\n```\n\n| :warning: | There's currently no support for mutating log messages. |\n| --- | ---- | \n\n### Registering Interceptors\nRegistering your own or built-in interceptors through the centralized `LogInterceptors` storage layer. \n```kotlin\nLogInterceptors.register(BadWordLogInterceptor) // applicable to all levels\nLogInterceptors.register(Level.WARN, ThreadBlockedLogInterceptor(registry)) // built-in interceptor\nLogInterceptors.register(Level.INFO, LogMessagesCounterInterceptor()) // counts all info messages\n```\n\n\n\n## Built-In Interceptors\n\n### ThreadBlockedLogInterceptor\nThis interceptor aims to capture thread blocks that are detect by Vert.x \n[BlockedThreadChecker](https://github.com/eclipse-vertx/vert.x/blob/3.9/src/main/java/io/vertx/core/impl/BlockedThreadChecker.java),\nproviding a metric around it.\n\nThe exported metric has the following properties:\n\n| Name | type | Tags | \n| --- | --- | --- | \n| `vertx_thread_blocked_total` | Counter | `thread`: the name of the blocked thread | \n\nNote that the metric name can be customized by specifying the optional `metricName` constructor parameter.\n\nFor the sake of illustration, the metric exported through a prometheus formatted endpoint:\n```\n# HELP vertx_thread_blocked_total Number of thread blocks detected\n# TYPE vertx_thread_blocked_total counter\nvertx_thread_blocked_total{thread=\"vert.x-eventloop-thread-0,5,main\",} 1.0\n```\n\n## Building \nAt the project root, run the following command:\n```shell\n./gradlew clean build\n```\n\nThe above command will run both the tests and verification checks.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidafsilva%2Fvertx-logging-interceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidafsilva%2Fvertx-logging-interceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidafsilva%2Fvertx-logging-interceptor/lists"}