@@ -13,6 +13,8 @@ import org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.{OWLNothing,
1313import org .semanticweb .owlapi .apibinding .OWLManager
1414import org .semanticweb .owlapi .model ._
1515import org .semanticweb .owlapi .model .parameters .Imports
16+ import scribe .Level
17+ import scribe .filter .{packageName , select }
1618import zio ._
1719import zio .blocking ._
1820import zio .stream ._
@@ -38,14 +40,22 @@ object Main extends ZCaseApp[Config] {
3840 private val OWLOntology = OWL2 .Ontology .asNode
3941
4042 override def run (config : Config , arg : RemainingArgs ): ZIO [ZEnv , Nothing , ExitCode ] = {
43+ val configureLogging = ZIO .succeed {
44+ scribe.Logger .root
45+ .clearHandlers()
46+ .clearModifiers()
47+ .withModifier(select(packageName(" org.renci.relationgraph" )).boosted(Level .Info , Level .Warn ))
48+ .withHandler(minimumLevel = Some (if (config.verbose) Level .Info else Level .Warn ))
49+ .replace()
50+ }
4151 val program = createStreamRDF(config.outputFile).use { rdfWriter =>
4252 for {
4353 fileProperties <- config.propertiesFile.map(readPropertiesFile).getOrElse(ZIO .succeed(Set .empty[AtomicConcept ]))
4454 specifiedProperties = fileProperties ++ config.property.map(prop => AtomicConcept (prop)).to(Set )
4555 ontology <- loadOntology(config.ontologyFile)
4656 whelkOntology = Bridge .ontologyToAxioms(ontology)
4757 _ <- ZIO .succeed(scribe.info(" Running reasoner" ))
48- whelk = Reasoner .assert(whelkOntology)
58+ whelk = Reasoner .assert(whelkOntology, disableBottom = config.disableOwlNothing.bool )
4959 indexedWhelk = IndexedReasonerState (whelk)
5060 _ <- ZIO .succeed(scribe.info(" Done running reasoner" ))
5161 _ <- ZIO .fail(new Exception (" Ontology is incoherent; please correct unsatisfiable classes." )).when(isIncoherent(whelk))
@@ -60,7 +70,12 @@ object Main extends ZCaseApp[Config] {
6070 _ <- ZIO .succeed(scribe.info(s " Computed relations in ${(stop - start) / 1000.0 }s " ))
6171 } yield ()
6272 }
63- program.exitCode
73+ configureLogging *>
74+ program.as(ExitCode .success)
75+ .catchAll { e =>
76+ if (config.verbose) ZIO .succeed(e.printStackTrace()).as(ExitCode .failure)
77+ else ZIO .succeed(scribe.error(e.getMessage)).as(ExitCode .failure)
78+ }
6479 }
6580
6681 def computeRelations (ontology : OWLOntology , whelk : IndexedReasonerState , specifiedProperties : Set [AtomicConcept ], outputSubclasses : Boolean , reflexiveSubclasses : Boolean , equivalenceAsSubclass : Boolean , mode : Config .OutputMode ): UStream [TriplesGroup ] = {
0 commit comments