Improve logging

This commit is contained in:
Eike Kettner 2021-01-20 00:40:58 +01:00
parent 27c24c128d
commit b12d965223
3 changed files with 12 additions and 6 deletions

View File

@ -25,8 +25,9 @@ object Classify {
text: String text: String
)(cname: ClassifierName): F[Option[String]] = )(cname: ClassifierName): F[Option[String]] =
(for { (for {
_ <- OptionT.liftF(logger.info(s"Guessing label for ${cname.name}")) _ <- OptionT.liftF(logger.info(s"Guessing label for ${cname.name}"))
model <- OptionT(store.transact(RClassifierModel.findByName(coll, cname.name))) model <- OptionT(store.transact(RClassifierModel.findByName(coll, cname.name)))
.flatTapNone(logger.debug("No classifier model found."))
modelData = modelData =
store.bitpeace store.bitpeace
.get(model.fileId.id) .get(model.fileId.id)
@ -40,6 +41,7 @@ object Classify {
.drain .drain
.flatMap(_ => classifier.classify(logger, ClassifierModel(modelFile), text)) .flatMap(_ => classifier.classify(logger, ClassifierModel(modelFile), text))
}).filter(_ != LearnClassifierTask.noClass) }).filter(_ != LearnClassifierTask.noClass)
.flatTapNone(logger.debug("Guessed: <none>"))
_ <- OptionT.liftF(logger.debug(s"Guessed: ${cls}")) _ <- OptionT.liftF(logger.debug(s"Guessed: ${cls}"))
} yield cls).value } yield cls).value

View File

@ -37,8 +37,7 @@ object TextAnalysis {
_ <- t.traverse(m => _ <- t.traverse(m =>
ctx.store.transact(RAttachmentMeta.updateLabels(m._1.id, m._1.nerlabels)) ctx.store.transact(RAttachmentMeta.updateLabels(m._1.id, m._1.nerlabels))
) )
e <- s
_ <- ctx.logger.info(s"Text-Analysis finished in ${e.formatExact}")
v = t.toVector v = t.toVector
autoTagEnabled <- getActiveAutoTag(ctx, cfg) autoTagEnabled <- getActiveAutoTag(ctx, cfg)
tag <- tag <-
@ -50,6 +49,8 @@ object TextAnalysis {
predictItemEntities(ctx, cfg, item.metas, analyser.classifier) predictItemEntities(ctx, cfg, item.metas, analyser.classifier)
else MetaProposalList.empty.pure[F] else MetaProposalList.empty.pure[F]
e <- s
_ <- ctx.logger.info(s"Text-Analysis finished in ${e.formatExact}")
} yield item } yield item
.copy( .copy(
metas = v.map(_._1), metas = v.map(_._1),
@ -109,7 +110,6 @@ object TextAnalysis {
mtype: MetaProposalType mtype: MetaProposalType
): F[Option[MetaProposal]] = ): F[Option[MetaProposal]] =
for { for {
_ <- ctx.logger.debug(s"Guessing $mtype using classifier")
label <- makeClassify(ctx, cfg, classifier)(text).apply(cname) label <- makeClassify(ctx, cfg, classifier)(text).apply(cname)
} yield label.map(str => } yield label.map(str =>
MetaProposal(mtype, Candidate(IdRef(Ident.unsafe(""), str), Set.empty)) MetaProposal(mtype, Candidate(IdRef(Ident.unsafe(""), str), Set.empty))

View File

@ -46,10 +46,14 @@ object TextExtraction {
) )
_ <- fts.indexData(ctx.logger, (idxItem +: txt.map(_.td)).toSeq: _*) _ <- fts.indexData(ctx.logger, (idxItem +: txt.map(_.td)).toSeq: _*)
dur <- start dur <- start
_ <- ctx.logger.info(s"Text extraction finished in ${dur.formatExact}") extractedTags = txt.flatMap(_.tags).distinct.toList
_ <- ctx.logger.info(s"Text extraction finished in ${dur.formatExact}.")
_ <-
if (extractedTags.isEmpty) ().pure[F]
else ctx.logger.debug(s"Found tags in file: $extractedTags")
} yield item } yield item
.copy(metas = txt.map(_.am)) .copy(metas = txt.map(_.am))
.appendTags(txt.flatMap(_.tags).distinct.toList) .appendTags(extractedTags)
} }
// -- helpers // -- helpers