mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Adopt to new loggin api
This commit is contained in:
@ -21,6 +21,17 @@ docspell.server {
|
||||
# other nodes can reach this server.
|
||||
internal-url = "http://localhost:7880"
|
||||
|
||||
# Configures logging
|
||||
logging {
|
||||
# The format for the log messages. Can be one of:
|
||||
# Json, Logfmt, Fancy or Plain
|
||||
format = "Json"
|
||||
|
||||
# The minimum level to log. From lowest to highest:
|
||||
# Trace, Debug, Info, Warn, Error
|
||||
minimumLevel = "Debug"
|
||||
}
|
||||
|
||||
# Where the server binds to.
|
||||
bind {
|
||||
address = "localhost"
|
||||
|
@ -10,6 +10,7 @@ import docspell.backend.auth.Login
|
||||
import docspell.backend.{Config => BackendConfig}
|
||||
import docspell.common._
|
||||
import docspell.ftssolr.SolrConfig
|
||||
import docspell.logging.LogConfig
|
||||
import docspell.oidc.ProviderConfig
|
||||
import docspell.pubsub.naive.PubSubConfig
|
||||
import docspell.restserver.Config.OpenIdConfig
|
||||
@ -23,6 +24,7 @@ case class Config(
|
||||
appId: Ident,
|
||||
baseUrl: LenientUri,
|
||||
internalUrl: LenientUri,
|
||||
logging: LogConfig,
|
||||
bind: Config.Bind,
|
||||
backend: BackendConfig,
|
||||
auth: Login.Config,
|
||||
|
@ -12,7 +12,6 @@ import cats.Monoid
|
||||
import cats.effect.Async
|
||||
|
||||
import docspell.backend.signup.{Config => SignupConfig}
|
||||
import docspell.common.Logger
|
||||
import docspell.config.Implicits._
|
||||
import docspell.config.{ConfigFactory, Validation}
|
||||
import docspell.oidc.{ProviderConfig, SignatureAlgo}
|
||||
@ -23,11 +22,12 @@ import pureconfig.generic.auto._
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
object ConfigFile {
|
||||
private[this] val unsafeLogger = org.log4s.getLogger
|
||||
private[this] val unsafeLogger = docspell.logging.unsafeLogger
|
||||
|
||||
import Implicits._
|
||||
|
||||
def loadConfig[F[_]: Async](args: List[String]): F[Config] = {
|
||||
val logger = Logger.log4s(unsafeLogger)
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val validate =
|
||||
Validation.of(generateSecretIfEmpty, duplicateOpenIdProvider, signKeyVsUserUrl)
|
||||
ConfigFactory
|
||||
|
@ -9,17 +9,17 @@ package docspell.restserver
|
||||
import cats.effect._
|
||||
|
||||
import docspell.common._
|
||||
|
||||
import org.log4s.getLogger
|
||||
import docspell.logging.impl.ScribeConfigure
|
||||
|
||||
object Main extends IOApp {
|
||||
private[this] val logger: Logger[IO] = Logger.log4s(getLogger)
|
||||
|
||||
private val connectEC =
|
||||
ThreadFactories.fixed[IO](5, ThreadFactories.ofName("docspell-dbconnect"))
|
||||
|
||||
def run(args: List[String]) = for {
|
||||
cfg <- ConfigFile.loadConfig[IO](args)
|
||||
_ <- ScribeConfigure.configure[IO](cfg.logging)
|
||||
logger = docspell.logging.getLogger[IO]
|
||||
banner = Banner(
|
||||
"REST Server",
|
||||
BuildInfo.version,
|
||||
|
@ -11,7 +11,6 @@ import fs2.Stream
|
||||
import fs2.concurrent.Topic
|
||||
|
||||
import docspell.backend.BackendApp
|
||||
import docspell.common.Logger
|
||||
import docspell.ftsclient.FtsClient
|
||||
import docspell.ftssolr.SolrFtsClient
|
||||
import docspell.notification.api.NotificationModule
|
||||
@ -47,7 +46,8 @@ object RestAppImpl {
|
||||
pubSub: PubSub[F],
|
||||
wsTopic: Topic[F, OutputEvent]
|
||||
): Resource[F, RestApp[F]] = {
|
||||
val logger = Logger.log4s(org.log4s.getLogger(s"restserver-${cfg.appId.id}"))
|
||||
val logger = docspell.logging.getLogger[F](s"restserver-${cfg.appId.id}")
|
||||
|
||||
for {
|
||||
ftsClient <- createFtsClient(cfg)(httpClient)
|
||||
pubSubT = PubSubT(pubSub, logger)
|
||||
|
@ -22,10 +22,8 @@ import io.circe.Json
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
import org.http4s.headers.Location
|
||||
import org.http4s.{Response, Uri}
|
||||
import org.log4s.getLogger
|
||||
|
||||
object OpenId {
|
||||
private[this] val log = getLogger
|
||||
|
||||
def codeFlowConfig[F[_]](config: Config): CodeFlowConfig[F] =
|
||||
CodeFlowConfig(
|
||||
@ -38,9 +36,9 @@ object OpenId {
|
||||
|
||||
def handle[F[_]: Async](backend: BackendApp[F], config: Config): OnUserInfo[F] =
|
||||
OnUserInfo { (req, provider, userInfo) =>
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
val logger = Logger.log4s(log)
|
||||
val baseUrl = ClientRequestInfo.getBaseUrl(config, req)
|
||||
val uri = baseUrl.withQuery("openid", "1") / "app" / "login"
|
||||
val location = Location(Uri.unsafeFromString(uri.asString))
|
||||
@ -101,6 +99,7 @@ object OpenId {
|
||||
location: Location,
|
||||
baseUrl: LenientUri
|
||||
): F[Response[F]] = {
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
@ -108,7 +107,6 @@ object OpenId {
|
||||
setup <- backend.signup.setupExternal(cfg.backend.signup)(
|
||||
ExternalAccount(accountId)
|
||||
)
|
||||
logger = Logger.log4s(log)
|
||||
res <- setup match {
|
||||
case SignupResult.Failure(ex) =>
|
||||
logger.error(ex)(s"Error when creating external account!") *>
|
||||
@ -141,6 +139,7 @@ object OpenId {
|
||||
location: Location,
|
||||
baseUrl: LenientUri
|
||||
): F[Response[F]] = {
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
@ -160,7 +159,7 @@ object OpenId {
|
||||
.map(_.addCookie(CookieData(session).asCookie(baseUrl)))
|
||||
|
||||
case failed =>
|
||||
Logger.log4s(log).error(s"External login failed: $failed") *>
|
||||
logger.error(s"External login failed: $failed") *>
|
||||
SeeOther(location)
|
||||
}
|
||||
} yield resp
|
||||
|
@ -27,8 +27,7 @@ object ClientSettingsRoutes {
|
||||
backend: BackendApp[F],
|
||||
token: ShareToken
|
||||
): HttpRoutes[F] = {
|
||||
val logger = Logger.log4s[F](org.log4s.getLogger)
|
||||
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
|
@ -22,16 +22,15 @@ import org.http4s.HttpRoutes
|
||||
import org.http4s.circe.CirceEntityDecoder._
|
||||
import org.http4s.circe.CirceEntityEncoder._
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
import org.log4s.getLogger
|
||||
|
||||
object ItemMultiRoutes extends NonEmptyListSupport with MultiIdSupport {
|
||||
private[this] val log4sLogger = getLogger
|
||||
|
||||
def apply[F[_]: Async](
|
||||
cfg: Config,
|
||||
backend: BackendApp[F],
|
||||
user: AuthToken
|
||||
): HttpRoutes[F] = {
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
@ -236,7 +235,6 @@ object ItemMultiRoutes extends NonEmptyListSupport with MultiIdSupport {
|
||||
for {
|
||||
json <- req.as[IdList]
|
||||
items <- requireNonEmpty(json.ids)
|
||||
logger = Logger.log4s(log4sLogger)
|
||||
res <- backend.item.merge(logger, items, user.account.collective)
|
||||
resp <- Ok(Conversions.basicResult(res, "Items merged"))
|
||||
} yield resp
|
||||
|
@ -18,7 +18,6 @@ import docspell.backend.ops.OItemSearch.{Batch, Query}
|
||||
import docspell.backend.ops.OSimpleSearch
|
||||
import docspell.backend.ops.OSimpleSearch.StringSearchResult
|
||||
import docspell.common._
|
||||
import docspell.common.syntax.all._
|
||||
import docspell.query.FulltextExtract.Result.TooMany
|
||||
import docspell.query.FulltextExtract.Result.UnsupportedPosition
|
||||
import docspell.restapi.model._
|
||||
@ -34,16 +33,14 @@ import org.http4s.circe.CirceEntityEncoder._
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
import org.http4s.headers._
|
||||
import org.http4s.{HttpRoutes, Response}
|
||||
import org.log4s._
|
||||
|
||||
object ItemRoutes {
|
||||
private[this] val logger = getLogger
|
||||
|
||||
def apply[F[_]: Async](
|
||||
cfg: Config,
|
||||
backend: BackendApp[F],
|
||||
user: AuthToken
|
||||
): HttpRoutes[F] = {
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
@ -322,7 +319,7 @@ object ItemRoutes {
|
||||
case req @ PUT -> Root / Ident(id) / "duedate" =>
|
||||
for {
|
||||
date <- req.as[OptionalDate]
|
||||
_ <- logger.fdebug(s"Setting item due date to ${date.date}")
|
||||
_ <- logger.debug(s"Setting item due date to ${date.date}")
|
||||
res <- backend.item.setItemDueDate(
|
||||
NonEmptyList.of(id),
|
||||
date.date,
|
||||
@ -334,7 +331,7 @@ object ItemRoutes {
|
||||
case req @ PUT -> Root / Ident(id) / "date" =>
|
||||
for {
|
||||
date <- req.as[OptionalDate]
|
||||
_ <- logger.fdebug(s"Setting item date to ${date.date}")
|
||||
_ <- logger.debug(s"Setting item date to ${date.date}")
|
||||
res <- backend.item.setItemDate(
|
||||
NonEmptyList.of(id),
|
||||
date.date,
|
||||
@ -353,7 +350,7 @@ object ItemRoutes {
|
||||
case req @ POST -> Root / Ident(id) / "attachment" / "movebefore" =>
|
||||
for {
|
||||
data <- req.as[MoveAttachment]
|
||||
_ <- logger.fdebug(s"Move item (${id.id}) attachment $data")
|
||||
_ <- logger.debug(s"Move item (${id.id}) attachment $data")
|
||||
res <- backend.item.moveAttachmentBefore(id, data.source, data.target)
|
||||
resp <- Ok(Conversions.basicResult(res, "Attachment moved."))
|
||||
} yield resp
|
||||
@ -390,7 +387,7 @@ object ItemRoutes {
|
||||
case req @ POST -> Root / Ident(id) / "reprocess" =>
|
||||
for {
|
||||
data <- req.as[IdList]
|
||||
_ <- logger.fdebug(s"Re-process item ${id.id}")
|
||||
_ <- logger.debug(s"Re-process item ${id.id}")
|
||||
res <- backend.item.reprocess(id, data.ids, user.account, true)
|
||||
resp <- Ok(Conversions.basicResult(res, "Re-process task submitted."))
|
||||
} yield resp
|
||||
|
@ -135,7 +135,8 @@ object NotificationRoutes extends NonEmptyListSupport {
|
||||
user.account,
|
||||
baseUrl.some
|
||||
)
|
||||
resp <- Ok(NotificationChannelTestResult(res.success, res.logMessages.toList))
|
||||
messages = res.logEvents.map(_.asString)
|
||||
resp <- Ok(NotificationChannelTestResult(res.success, messages.toList))
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import docspell.backend.BackendApp
|
||||
import docspell.backend.auth.AuthToken
|
||||
import docspell.backend.ops.OOrganization
|
||||
import docspell.common.Ident
|
||||
import docspell.common.syntax.all._
|
||||
import docspell.restapi.model._
|
||||
import docspell.restserver.conv.Conversions._
|
||||
import docspell.restserver.http4s.QueryParam
|
||||
@ -23,12 +22,11 @@ import org.http4s.HttpRoutes
|
||||
import org.http4s.circe.CirceEntityDecoder._
|
||||
import org.http4s.circe.CirceEntityEncoder._
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
import org.log4s._
|
||||
|
||||
object PersonRoutes {
|
||||
private[this] val logger = getLogger
|
||||
|
||||
def apply[F[_]: Async](backend: BackendApp[F], user: AuthToken): HttpRoutes[F] = {
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
@ -73,7 +71,7 @@ object PersonRoutes {
|
||||
|
||||
case DELETE -> Root / Ident(id) =>
|
||||
for {
|
||||
_ <- logger.fdebug(s"Deleting person ${id.id}")
|
||||
_ <- logger.debug(s"Deleting person ${id.id}")
|
||||
delOrg <- backend.organization.deletePerson(id, user.account.collective)
|
||||
resp <- Ok(basicResult(delOrg, "Person deleted."))
|
||||
} yield resp
|
||||
|
@ -33,7 +33,7 @@ object ShareSearchRoutes {
|
||||
cfg: Config,
|
||||
token: ShareToken
|
||||
): HttpRoutes[F] = {
|
||||
val logger = Logger.log4s[F](org.log4s.getLogger)
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
@ -21,12 +21,10 @@ import org.http4s._
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
import org.http4s.headers._
|
||||
import org.http4s.implicits._
|
||||
import org.log4s._
|
||||
import yamusca.implicits._
|
||||
import yamusca.imports._
|
||||
|
||||
object TemplateRoutes {
|
||||
private[this] val logger = getLogger
|
||||
|
||||
private val textHtml = mediaType"text/html"
|
||||
private val appJavascript = mediaType"application/javascript"
|
||||
@ -99,11 +97,12 @@ object TemplateRoutes {
|
||||
def parseTemplate[F[_]: Sync](str: String): F[Template] =
|
||||
Sync[F].pure(mustache.parse(str).leftMap(err => new Exception(err._2))).rethrow
|
||||
|
||||
def loadTemplate[F[_]: Sync](url: URL): F[Template] =
|
||||
loadUrl[F](url).flatMap(parseTemplate[F]).map { t =>
|
||||
logger.info(s"Compiled template $url")
|
||||
t
|
||||
def loadTemplate[F[_]: Sync](url: URL): F[Template] = {
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
loadUrl[F](url).flatMap(parseTemplate[F]).flatMap { t =>
|
||||
logger.info(s"Compiled template $url") *> t.pure[F]
|
||||
}
|
||||
}
|
||||
|
||||
case class DocData(swaggerRoot: String, openapiSpec: String)
|
||||
object DocData {
|
||||
|
Reference in New Issue
Block a user