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

Remove logback dependency #716

Merged
merged 3 commits into from
Apr 12, 2024
Merged
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
1 change: 0 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ kotlin {
val jvmMain by getting {
dependencies {
implementation(libs.ktor.http)
implementation(libs.logback)
implementation(libs.rss.reader)
api(libs.jackson)
api(libs.jackson.schema)
Expand Down
1 change: 0 additions & 1 deletion core/src/commonTest/resources/logback-test.xml

This file was deleted.

11 changes: 0 additions & 11 deletions detekt-rules/src/main/resources/logback.xml

This file was deleted.

1 change: 0 additions & 1 deletion integrations/gcp/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ kotlin {
...
val jvmMain by getting {
dependencies {
implementation(libs.logback)
api(libs.ktor.client.cio)
}
}
Expand Down
1 change: 0 additions & 1 deletion integrations/gcp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ kotlin {
}
val jvmMain by getting {
dependencies {
implementation(libs.logback)
api(libs.ktor.client.cio)
}
}
Expand Down
1 change: 0 additions & 1 deletion integrations/mlflow/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ kotlin {
}
val jvmMain by getting {
dependencies {
implementation(libs.logback)
api(libs.ktor.client.cio)
}
}
Expand Down
1 change: 0 additions & 1 deletion openai-client/client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ kotlin {
}
val jvmMain by getting {
dependencies {
implementation(libs.logback)
api(libs.ktor.client.cio)
}
}
Expand Down
1 change: 0 additions & 1 deletion reasoning/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ kotlin {
}
val jvmMain by getting {
dependencies {
implementation(libs.logback)
implementation(projects.xefPdf)
implementation(projects.xefFilesystem)
api(libs.ktor.client.cio)
Expand Down
1 change: 0 additions & 1 deletion server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ dependencies {
implementation(libs.ktor.server.cors)
implementation(libs.ktor.server.request.validation)
implementation(libs.ktor.server.status.pages)
implementation(libs.logback)
implementation(libs.suspendApp.core)
implementation(libs.suspendApp.ktor)
implementation(libs.uuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.xebia.functional.xef.server.http.routes.xefRoutes
import com.xebia.functional.xef.server.services.hikariDataSource
import com.xebia.functional.xef.server.services.vectorStoreService
import com.xebia.functional.xef.store.migrations.runDatabaseMigrations
import io.github.oshai.kotlinlogging.KotlinLogging
import io.ktor.client.HttpClient
import io.ktor.client.engine.cio.CIO
import io.ktor.client.plugins.auth.Auth
Expand All @@ -30,13 +31,12 @@ import io.ktor.server.resources.Resources
import io.ktor.server.routing.routing
import kotlinx.coroutines.awaitCancellation
import org.jetbrains.exposed.sql.Database
import org.slf4j.LoggerFactory

object Server {
@JvmStatic
fun main(args: Array<String>) = SuspendApp {
resourceScope {
val logger = LoggerFactory.getLogger("xef-server")
val logger = KotlinLogging.logger("xef-server")

val config = ConfigFactory.load("database.conf").resolve()
val xefDBConfig = XefDatabaseConfig.load("xef-database", config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import com.xebia.functional.xef.server.services.OrganizationRepositoryService
import com.xebia.functional.xef.server.services.ProjectRepositoryService
import com.xebia.functional.xef.server.services.TokenRepositoryService
import com.xebia.functional.xef.server.services.UserRepositoryService
import io.github.oshai.kotlinlogging.KLogger
import io.ktor.server.routing.*
import org.slf4j.Logger

fun Routing.xefRoutes(logger: Logger) {
fun Routing.xefRoutes(logger: KLogger) {
userRoutes(UserRepositoryService(logger))
organizationRoutes(OrganizationRepositoryService(logger))
projectsRoutes(ProjectRepositoryService(logger))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import com.xebia.functional.xef.server.db.tables.Organization
import com.xebia.functional.xef.server.db.tables.User
import com.xebia.functional.xef.server.models.*
import com.xebia.functional.xef.server.models.exceptions.XefExceptions.*
import io.github.oshai.kotlinlogging.KLogger
import kotlinx.datetime.Clock
import org.jetbrains.exposed.sql.SizedCollection
import org.jetbrains.exposed.sql.transactions.transaction
import org.slf4j.Logger

class OrganizationRepositoryService(private val logger: Logger) {
class OrganizationRepositoryService(private val logger: KLogger) {
fun createOrganization(data: OrganizationRequest, token: Token): OrganizationSimpleResponse {
logger.info("Creating organization with name: ${data.name}")
logger.info { "Creating organization with name: ${data.name}" }
return transaction {
// Getting the user from the token
val user = token.getUser()
Expand All @@ -30,7 +30,7 @@ class OrganizationRepositoryService(private val logger: Logger) {
}

fun getOrganizations(token: Token): List<OrganizationFullResponse> {
logger.info("Getting organizations")
logger.info { "Getting organizations" }
return transaction {
// Getting the user from the token
val user = token.getUser()
Expand All @@ -41,7 +41,7 @@ class OrganizationRepositoryService(private val logger: Logger) {
}

fun getOrganization(token: Token, id: Int): OrganizationFullResponse {
logger.info("Getting organizations")
logger.info { "Getting organizations" }
return transaction {
// Getting the user from the token
val user = token.getUser()
Expand All @@ -53,7 +53,7 @@ class OrganizationRepositoryService(private val logger: Logger) {
}

fun getUsersInOrganization(token: Token, id: Int): List<UserResponse> {
logger.info("Getting users in organization")
logger.info { "Getting users in organization" }
return transaction {
// Getting the user from the token
val user = token.getUser()
Expand All @@ -71,7 +71,7 @@ class OrganizationRepositoryService(private val logger: Logger) {
data: OrganizationUpdateRequest,
id: Int
): OrganizationFullResponse {
logger.info("Updating organization with name: ${data.name}")
logger.info { "Updating organization with name: ${data.name}" }
return transaction {
// Getting the user from the token
val user = token.getUser()
Expand All @@ -95,7 +95,7 @@ class OrganizationRepositoryService(private val logger: Logger) {
}

fun deleteOrganization(token: Token, id: Int) {
logger.info("Deleting organization with id: $id")
logger.info { "Deleting organization with id: $id" }
transaction {
val user = token.getUser()
val organization =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import com.xebia.functional.xef.store.VectorStore
import com.xebia.functional.xef.store.postgresql.PGDistanceStrategy
import com.xebia.functional.xef.store.postgresql.addNewCollection
import com.xebia.functional.xef.store.postgresql.connection
import io.github.oshai.kotlinlogging.KLogger
import javax.sql.DataSource
import kotlinx.uuid.UUID
import kotlinx.uuid.generateUUID
import org.slf4j.Logger

class PostgresVectorStoreService(
private val logger: Logger,
private val logger: KLogger,
private val dataSource: DataSource,
private val collectionName: String,
private val vectorSize: Int,
Expand All @@ -33,7 +33,7 @@ class PostgresVectorStoreService(
bind(uuid.toString())
bind(collectionName)
}
.also { logger.info("Created collection $collectionName") }
.also { logger.info { "Created collection $collectionName" } }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.xebia.functional.xef.server.services
import com.xebia.functional.xef.server.db.tables.*
import com.xebia.functional.xef.server.models.*
import com.xebia.functional.xef.server.models.exceptions.XefExceptions.*
import io.github.oshai.kotlinlogging.KLogger
import kotlinx.datetime.Clock
import org.jetbrains.exposed.sql.transactions.transaction
import org.slf4j.Logger

class ProjectRepositoryService(private val logger: Logger) {
class ProjectRepositoryService(private val logger: KLogger) {
fun createProject(data: ProjectRequest, token: Token): ProjectSimpleResponse {
logger.info("Creating project with name: ${data.name}")
logger.info { "Creating project with name: ${data.name}" }
return transaction {
val user = token.getUser()

Expand All @@ -30,7 +30,7 @@ class ProjectRepositoryService(private val logger: Logger) {
}

fun getProjects(token: Token): List<ProjectFullResponse> {
logger.info("Getting projects")
logger.info { "Getting projects" }
return transaction {
val user = token.getUser()

Expand All @@ -43,7 +43,7 @@ class ProjectRepositoryService(private val logger: Logger) {
}

fun getProject(token: Token, id: Int): ProjectFullResponse {
logger.info("Getting project")
logger.info { "Getting project" }
return transaction {
val user = token.getUser()

Expand All @@ -58,7 +58,7 @@ class ProjectRepositoryService(private val logger: Logger) {
}

fun getProjectsByOrganization(token: Token, orgId: Int): List<ProjectSimpleResponse> {
logger.info("Getting projects")
logger.info { "Getting projects" }
return transaction {
val user = token.getUser()

Expand All @@ -71,7 +71,7 @@ class ProjectRepositoryService(private val logger: Logger) {
}

fun updateProject(token: Token, data: ProjectUpdateRequest, id: Int): ProjectFullResponse {
logger.info("Updating project with name: ${data.name}")
logger.info { "Updating project with name: ${data.name}" }
return transaction {
val user = token.getUser()

Expand Down Expand Up @@ -101,7 +101,7 @@ class ProjectRepositoryService(private val logger: Logger) {
}

fun deleteProject(token: Token, id: Int) {
logger.info("Deleting project with id: $id")
logger.info { "Deleting project with id: $id" }
transaction {
val user = token.getUser()
val project = Project.findById(id) ?: throw ProjectException("Project not found")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import com.xebia.functional.xef.server.db.tables.XefTokens
import com.xebia.functional.xef.server.db.tables.XefTokensTable
import com.xebia.functional.xef.server.models.*
import com.xebia.functional.xef.server.models.exceptions.XefExceptions.*
import io.github.oshai.kotlinlogging.KLogger
import java.util.UUID
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.transactions.transaction
import org.slf4j.Logger

class TokenRepositoryService(private val logger: Logger) {
class TokenRepositoryService(private val logger: KLogger) {
fun createToken(data: TokenRequest, userToken: Token): TokenSimpleResponse {
return transaction {
val user = userToken.getUser()

val project =
Project.findById(data.projectId) ?: throw OrganizationsException("Project not found")

logger.info("Creating token with name ${data.name} from project ${project.name}")
logger.info { "Creating token with name ${data.name} from project ${project.name}" }

if (user.organizations.none { it.id == project.orgId }) {
throw OrganizationsException(
Expand All @@ -43,7 +43,7 @@ class TokenRepositoryService(private val logger: Logger) {
}

fun getTokens(userToken: Token): List<TokenFullResponse> {
logger.info("Getting tokens")
logger.info { "Getting tokens" }
return transaction {
val user = userToken.getUser()

Expand All @@ -64,7 +64,7 @@ class TokenRepositoryService(private val logger: Logger) {
}

fun getTokensByProject(userToken: Token, projectId: Int): List<TokenFullResponse> {
logger.info("Getting tokens by project")
logger.info { "Getting tokens by project" }
return transaction {
val user = userToken.getUser()

Expand All @@ -78,7 +78,7 @@ class TokenRepositoryService(private val logger: Logger) {
}

fun updateToken(userToken: Token, data: TokenUpdateRequest, id: Int): TokenFullResponse {
logger.info("Updating token with name: ${data.name}")
logger.info { "Updating token with name: ${data.name}" }
return transaction {
val user = userToken.getUser()

Expand All @@ -102,7 +102,7 @@ class TokenRepositoryService(private val logger: Logger) {
}

fun deleteToken(userToken: Token, id: Int) {
logger.info("Deleting token: $id")
logger.info { "Deleting token: $id" }
transaction {
val user = userToken.getUser()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import com.xebia.functional.xef.server.models.LoginResponse
import com.xebia.functional.xef.server.models.RegisterRequest
import com.xebia.functional.xef.server.models.exceptions.XefExceptions.UserException
import com.xebia.functional.xef.server.utils.HashUtils
import io.github.oshai.kotlinlogging.KLogger
import kotlinx.uuid.UUID
import kotlinx.uuid.generateUUID
import org.jetbrains.exposed.sql.transactions.transaction
import org.slf4j.Logger

class UserRepositoryService(private val logger: Logger) {
class UserRepositoryService(private val logger: KLogger) {

fun register(request: RegisterRequest): LoginResponse {
logger.info("Registering user ${request.email}")
logger.info { "Registering user ${request.email}" }

return transaction {
if (User.find { UsersTable.email eq request.email }.count() > 0) {
Expand All @@ -38,7 +38,7 @@ class UserRepositoryService(private val logger: Logger) {
}

fun login(request: LoginRequest): LoginResponse {
logger.info("Login user ${request.email}")
logger.info { "Login user ${request.email}" }
return transaction {
val user =
User.find { UsersTable.email eq request.email }.firstOrNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import com.typesafe.config.Config
import com.xebia.functional.xef.store.VectorStore
import com.xebia.functional.xef.store.config.PostgreSQLVectorStoreConfig
import com.xebia.functional.xef.store.migrations.runDatabaseMigrations
import io.github.oshai.kotlinlogging.KLogger
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.hocon.Hocon
import org.slf4j.Logger

enum class XefVectorStoreType {
PSQL,
Expand All @@ -27,7 +27,7 @@ enum class XefVectorStoreType {
suspend fun ResourceScope.vectorStoreService(
configNamespace: String,
config: Config,
logger: Logger
logger: KLogger
): VectorStoreService =
withContext(Dispatchers.IO) {
val vectorStoreConfig = config.getConfig(configNamespace)
Expand Down