@@ -10,6 +10,8 @@ import es.weso.shex.validator.Validator
1010import es .weso .shextest .manifest .{Validate => _ , _ }
1111import com .monovore .decline ._
1212import com .monovore .decline .effect ._
13+ import com .typesafe .scalalogging .LazyLogging
14+
1315// import buildinfo._
1416import java .nio .file .Path
1517import es .weso .shapepath .schemamappings .SchemaMappings
@@ -45,7 +47,8 @@ object Main
4547 name = " shex-s" ,
4648 header = " ShEx-Scala command line tool" ,
4749 version = " 0.2.2" // BuildInfo.version
48- ) {
50+ )
51+ with LazyLogging {
4952
5053 lazy val mappingOpt = Opts .option[Path ](
5154 " mapping" ,
@@ -72,7 +75,31 @@ object Main
7275 if (verbose) IO .println(msg)
7376 else IO (())
7477
75- override def main : Opts [IO [ExitCode ]] =
78+ private def disable_logs (): Unit = {
79+ // The following code is needed to remove extra logging from Jena
80+ import org .apache .jena .riot .system .stream .JenaIOEnvironment
81+ import org .apache .jena .riot .system .stream .LocationMapper
82+ val mapper : LocationMapper = new LocationMapper ()
83+ JenaIOEnvironment .setGlobalLocationMapper(mapper)
84+
85+ // Force logging level to None
86+ val log : ch.qos.logback.classic.Logger =
87+ logger.underlying.asInstanceOf [ch.qos.logback.classic.Logger ]
88+ log.getName()
89+ import org .slf4j .LoggerFactory
90+ import ch .qos .logback .classic ._
91+ val es_weso_log : ch.qos.logback.classic.Logger =
92+ LoggerFactory .getLogger(" es.weso" ).asInstanceOf [ch.qos.logback.classic.Logger ]
93+ val org_log : ch.qos.logback.classic.Logger =
94+ LoggerFactory .getLogger(" org" ).asInstanceOf [ch.qos.logback.classic.Logger ]
95+ org_log.setLevel(Level .OFF )
96+ es_weso_log.setLevel(Level .OFF )
97+ log.setLevel(Level .OFF )
98+
99+ }
100+
101+ override def main : Opts [IO [ExitCode ]] = {
102+ disable_logs()
76103 schemaMappingCommand
77104 .orElse(Validate .validateCommand)
78105 .orElse(shapePathValidateCommand)
@@ -90,6 +117,7 @@ object Main
90117 .map(
91118 _.handleErrorWith(infoError)
92119 )
120+ }
93121
94122 def infoError (err : Throwable ): IO [ExitCode ] =
95123 IO .println(s " Error ${err.getLocalizedMessage()}" ) *> IO (ExitCode .Error )
0 commit comments