Commit 33c73ef2 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[Core] enh: create logger service

parent 0607bc17
Pipeline #177 failed with stage
in 7 minutes and 17 seconds
......@@ -33,7 +33,6 @@ import org.openmole.core.communication.message._
import org.openmole.core.communication.storage._
import org.openmole.core.event.EventDispatcher
import org.openmole.core.fileservice.FileService
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference.Preference
import org.openmole.core.serializer._
import org.openmole.core.threadprovider.ThreadProvider
......@@ -46,6 +45,7 @@ import org.openmole.core.workflow.execution.Environment.RuntimeLog
import org.openmole.core.workflow.job.MoleJob
import org.openmole.tool.cache.KeyValueCache
import org.openmole.tool.lock._
import org.openmole.tool.outputredirection.OutputRedirection
import squants._
object Runtime extends JavaLogger {
......
......@@ -38,10 +38,10 @@ import org.openmole.tool.file._
import org.openmole.tool.hash._
import org.openmole.core.{ location, module }
import org.openmole.core.outputmanager.OutputManager
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference._
import org.openmole.core.services._
import org.openmole.core.networkservice._
import org.openmole.tool.outputredirection.OutputRedirection
object Application extends JavaLogger {
......
......@@ -2,9 +2,10 @@ package org.openmole.ui
import java.io.File
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.services.{ Services, ServicesContainer }
import org.openmole.tool.file._
import org.openmole.tool.logger.LoggerService
import org.openmole.tool.outputredirection.OutputRedirection
object Test {
def withTmpServices[T](f: Services T) = {
......@@ -41,6 +42,7 @@ object Test {
implicit val outputRedirection = OutputRedirection()
implicit val networkService = NetworkService(None)
implicit val fileServiceCache = FileServiceCache()
implicit val loggerService = LoggerService()
new ServicesContainer()
}
......
......@@ -82,13 +82,14 @@ def allThirdParties = Seq(
openmoleRandom,
openmoleNetwork,
openmoleException,
openmoleOutputRedirection,
txtmark)
lazy val openmoleCache = OsgiProject(thirdPartiesDir, "org.openmole.tool.cache", imports = Seq("*")) dependsOn (openmoleLogger) settings (thirdPartiesSettings: _*) settings (libraryDependencies += Libraries.squants, libraryDependencies += Libraries.cats)
lazy val openmoleTar = OsgiProject(thirdPartiesDir, "org.openmole.tool.tar", imports = Seq("*")) dependsOn (openmoleFile) settings (thirdPartiesSettings: _*)
lazy val openmoleFile = OsgiProject(thirdPartiesDir, "org.openmole.tool.file", imports = Seq("*")) dependsOn(openmoleLock, openmoleStream, openmoleLogger) settings (thirdPartiesSettings: _*)
lazy val openmoleLock = OsgiProject(thirdPartiesDir, "org.openmole.tool.lock", imports = Seq("*")) settings (thirdPartiesSettings: _*)
lazy val openmoleLogger = OsgiProject(thirdPartiesDir, "org.openmole.tool.logger", imports = Seq("*")) settings (thirdPartiesSettings: _*)
lazy val openmoleLogger = OsgiProject(thirdPartiesDir, "org.openmole.tool.logger", imports = Seq("*")) dependsOn(openmoleOutputRedirection) settings (thirdPartiesSettings: _*) settings (libraryDependencies += Libraries.sourceCode)
lazy val openmoleThread = OsgiProject(thirdPartiesDir, "org.openmole.tool.thread", imports = Seq("*")) dependsOn(openmoleLogger, openmoleCollection) settings (thirdPartiesSettings: _*) settings (libraryDependencies += Libraries.squants)
lazy val openmoleHash = OsgiProject(thirdPartiesDir, "org.openmole.tool.hash", imports = Seq("*")) dependsOn(openmoleFile, openmoleStream) settings (thirdPartiesSettings: _*)
lazy val openmoleStream = OsgiProject(thirdPartiesDir, "org.openmole.tool.stream", imports = Seq("*")) dependsOn (openmoleThread) settings(libraryDependencies += Libraries.collections, libraryDependencies += Libraries.squants) settings (thirdPartiesSettings: _*)
......@@ -101,6 +102,7 @@ lazy val openmoleOSGi = OsgiProject(thirdPartiesDir, "org.openmole.tool.osgi", i
lazy val openmoleRandom = OsgiProject(thirdPartiesDir, "org.openmole.tool.random", imports = Seq("*")) settings (thirdPartiesSettings: _*) settings(libraryDependencies += Libraries.math, Libraries.addScalaLang(scalaVersionValue)) dependsOn (openmoleCache)
lazy val openmoleNetwork = OsgiProject(thirdPartiesDir, "org.openmole.tool.network", imports = Seq("*")) settings (thirdPartiesSettings: _*)
lazy val openmoleException = OsgiProject(thirdPartiesDir, "org.openmole.tool.exception", imports = Seq("*")) settings (thirdPartiesSettings: _*)
lazy val openmoleOutputRedirection = OsgiProject(thirdPartiesDir, "org.openmole.tool.outputredirection", imports = Seq("*")) settings (thirdPartiesSettings: _*)
lazy val txtmark = OsgiProject(thirdPartiesDir, "com.quandora.txtmark", exports = Seq("com.github.rjeschke.txtmark.*"), imports = Seq("*")) settings (thirdPartiesSettings: _*)
......@@ -178,7 +180,6 @@ lazy val workflow = OsgiProject(coreDir, "org.openmole.core.workflow", imports =
preference,
expansion,
threadProvider,
outputRedirection,
code,
networkService,
keyword) settings (coreSettings: _*)
......@@ -218,7 +219,7 @@ lazy val workspace = OsgiProject(coreDir, "org.openmole.core.workspace", imports
lazy val authentication = OsgiProject(coreDir, "org.openmole.core.authentication", imports = Seq("*")) dependsOn(workspace, serializer) settings (coreSettings: _*)
lazy val services = OsgiProject(coreDir, "org.openmole.core.services", imports = Seq("*")) dependsOn(workspace, serializer, preference, fileService, networkService, threadProvider, replication, authentication, outputRedirection) settings (coreSettings: _*)
lazy val services = OsgiProject(coreDir, "org.openmole.core.services", imports = Seq("*")) dependsOn(workspace, serializer, preference, fileService, networkService, threadProvider, replication, authentication, openmoleOutputRedirection) settings (coreSettings: _*)
lazy val location = OsgiProject(coreDir, "org.openmole.core.location", imports = Seq("*")) dependsOn (exception) settings (coreSettings: _*)
......@@ -233,7 +234,7 @@ lazy val fileService = OsgiProject(coreDir, "org.openmole.core.fileservice", imp
libraryDependencies += Libraries.guava
)
lazy val networkService = OsgiProject(coreDir, "org.openmole.core.networkservice", imports = Seq("*")) dependsOn(tools, workspace, preference) settings (coreSettings: _*) settings (defaultActivator)
lazy val networkService = OsgiProject(coreDir, "org.openmole.core.networkservice", imports = Seq("*")) dependsOn(tools, workspace, preference) settings (coreSettings: _*) settings (defaultActivator)
lazy val threadProvider = OsgiProject(coreDir, "org.openmole.core.threadprovider", imports = Seq("*")) dependsOn(tools, preference) settings (coreSettings: _*) settings (defaultActivator)
......@@ -255,8 +256,6 @@ lazy val logconfig = OsgiProject(
lazy val outputManager = OsgiProject(coreDir, "org.openmole.core.outputmanager", imports = Seq("*")) dependsOn (openmoleStream) settings (coreSettings: _*) settings (defaultActivator)
lazy val outputRedirection = OsgiProject(coreDir, "org.openmole.core.outputredirection", imports = Seq("*")) settings (coreSettings: _*)
lazy val console = OsgiProject(coreDir, "org.openmole.core.console", global = true, imports = Seq("*"), exports = Seq("org.openmole.core.console.*", "$line5.*")) dependsOn (pluginManager) settings(
OsgiKeys.importPackage := Seq("*"),
Libraries.addScalaLang(scalaVersionValue),
......@@ -527,7 +526,7 @@ lazy val container = OsgiProject(pluginDir, "org.openmole.plugin.task.container"
lazy val care = OsgiProject(pluginDir, "org.openmole.plugin.task.care", imports = Seq("*")) dependsOn(systemexec, container) settings (
libraryDependencies += Libraries.scalatest) settings (pluginSettings: _*)
lazy val udocker = OsgiProject(pluginDir, "org.openmole.plugin.task.udocker", imports = Seq("!jawn.*", "*")) dependsOn(systemexec, container, outputRedirection, networkService, services) settings(
lazy val udocker = OsgiProject(pluginDir, "org.openmole.plugin.task.udocker", imports = Seq("!jawn.*", "*")) dependsOn(systemexec, container, openmoleOutputRedirection, networkService, services) settings(
libraryDependencies += Libraries.scalatest,
libraryDependencies += Libraries.circe,
libraryDependencies ++= Libraries.httpClient) settings (pluginSettings: _*)
......
......@@ -19,7 +19,6 @@ package org.openmole.core.expansion
import java.io.File
import org.openmole.core.console._
import org.openmole.core.context.Variable.openMOLENameSpace
import org.openmole.core.context._
import org.openmole.core.exception._
import org.openmole.core.fileservice.FileService
......
......@@ -13,8 +13,10 @@ import org.openmole.core.workspace._
import org.openmole.tool.crypto._
import org.openmole.tool.random._
import org.openmole.tool.file._
import org.openmole.core.outputredirection._
import org.openmole.tool.outputredirection._
import org.openmole.core.networkservice._
import org.openmole.tool.logger.LoggerService
import org.openmole.tool.outputredirection.OutputRedirection
package object services {
......@@ -67,6 +69,7 @@ package object services {
implicit val outputRedirection = OutputRedirection()
implicit val networkService = NetworkService(httpProxy)
implicit val fileServiceCache = FileServiceCache()
implicit val loggerService = LoggerService()
new ServicesContainer()
}
......@@ -106,7 +109,8 @@ package object services {
eventDispatcher: EventDispatcher = services.eventDispatcher,
outputRedirection: OutputRedirection = services.outputRedirection,
networkService: NetworkService = services.networkService,
fileServiceCache: FileServiceCache = services.fileServiceCache
fileServiceCache: FileServiceCache = services.fileServiceCache,
loggerService: LoggerService = services.loggerService
) =
new ServicesContainer()(
workspace = workspace,
......@@ -123,7 +127,8 @@ package object services {
randomProvider = randomProvider,
eventDispatcher = eventDispatcher,
outputRedirection = outputRedirection,
networkService = networkService
networkService = networkService,
loggerService = loggerService
)
}
......@@ -147,6 +152,7 @@ package object services {
implicit def outputRedirection: OutputRedirection
implicit def networkService: NetworkService
implicit def fileServiceCache: FileServiceCache
implicit def loggerService: LoggerService
}
/**
......@@ -182,6 +188,7 @@ package object services {
val eventDispatcher: EventDispatcher,
val outputRedirection: OutputRedirection,
val networkService: NetworkService,
val fileServiceCache: FileServiceCache) extends Services
val fileServiceCache: FileServiceCache,
val loggerService: LoggerService) extends Services
}
......@@ -22,13 +22,13 @@ import java.io.{ File, PrintStream }
import org.openmole.core.event.EventDispatcher
import org.openmole.core.fileservice.{ FileService, FileServiceCache }
import org.openmole.core.outputmanager.OutputManager
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference.Preference
import org.openmole.core.serializer._
import org.openmole.core.threadprovider._
import org.openmole.core.workspace._
import org.openmole.core.workflow.dsl._
import org.openmole.tool.cache._
import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.tool.random.Seeder
object MoleExecutionContext {
......
......@@ -35,6 +35,7 @@ import org.openmole.core.workflow.tools._
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.tool.cache._
import org.openmole.tool.lock._
import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.tool.random
import org.openmole.tool.random._
import org.openmole.tool.thread._
......
......@@ -3,12 +3,12 @@ package org.openmole.core.workflow.test
import org.openmole.core.event.EventDispatcher
import org.openmole.core.fileservice.{ FileService, FileServiceCache }
import org.openmole.core.networkservice.NetworkService
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference.Preference
import org.openmole.core.serializer.SerializerService
import org.openmole.core.threadprovider.ThreadProvider
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.tool.crypto.Cypher
import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.tool.random.{ RandomProvider, Seeder }
object Stubs {
......
......@@ -26,7 +26,6 @@ import org.openmole.tool.tar._
import org.openmole.core.outputmanager.OutputManager
import org.openmole.core.module
import org.openmole.core.market
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference.{ ConfigurationLocation, Preference }
import org.openmole.core.project._
import org.openmole.core.services.Services
......@@ -38,6 +37,7 @@ import org.openmole.gui.ext.tool.server.OMRouter
import org.openmole.gui.ext.tool.server.Utils.authenticationKeysFile
import org.openmole.gui.server.core.GUIServer.ApplicationControl
import org.openmole.tool.crypto.Cypher
import org.openmole.tool.outputredirection.OutputRedirection
import scala.collection.JavaConverters._
......
......@@ -35,7 +35,6 @@ import java.util.concurrent.atomic.AtomicReference
import org.openmole.core.authentication.AuthenticationStore
import org.openmole.core.event.EventDispatcher
import org.openmole.core.fileservice.{ FileService, FileServiceCache }
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference.Preference
import org.openmole.core.replication.ReplicaCatalog
import org.openmole.core.serializer.SerializerService
......@@ -49,6 +48,8 @@ import org.openmole.gui.ext.tool.server
import org.openmole.gui.ext.tool.server.{ AutowireServer, OMRouter }
import org.openmole.tool.crypto.Cypher
import org.openmole.tool.file._
import org.openmole.tool.logger.LoggerService
import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.tool.random.{ RandomProvider, Seeder }
import org.openmole.tool.stream._
import org.openmole.tool.tar._
......@@ -74,6 +75,7 @@ object GUIServices {
implicit def eventDispatcher: EventDispatcher = guiServices.eventDispatcher
implicit def networkService: NetworkService = guiServices.networkService
implicit def outputRedirection: OutputRedirection = guiServices.outputRedirection
implicit def loggerService: LoggerService = guiServices.loggerService
}
def apply(workspace: Workspace, httpProxy: Option[String]) = {
......@@ -91,6 +93,7 @@ object GUIServices {
implicit val networkService = NetworkService(httpProxy)
implicit val fileServiceCache = FileServiceCache()
implicit val replicaCatalog = ReplicaCatalog(ws)
implicit val loggerService = LoggerService()
new GUIServices()
}
......@@ -123,7 +126,8 @@ class GUIServices(
val randomProvider: RandomProvider,
val eventDispatcher: EventDispatcher,
val outputRedirection: OutputRedirection,
val networkService: NetworkService
val networkService: NetworkService,
val loggerService: LoggerService
)
object GUIServlet {
......
......@@ -21,6 +21,7 @@ import org.openmole.core.workflow.task._
import org.openmole.core.workflow.validation._
import org.openmole.plugin.task.container
import org.openmole.plugin.tool.json._
import org.openmole.tool.outputredirection.OutputRedirection
object RTask {
......
......@@ -7,7 +7,6 @@ import org.openmole.core.exception.{ InternalProcessingError, UserBadDataError }
import org.openmole.core.expansion._
import org.openmole.core.fileservice.FileService
import org.openmole.core.networkservice.NetworkService
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference.Preference
import org.openmole.core.threadprovider.ThreadProvider
import org.openmole.core.workflow.builder._
......@@ -19,6 +18,7 @@ import org.openmole.plugin.task.container
import org.openmole.plugin.task.container._
import org.openmole.plugin.task.external._
import org.openmole.plugin.task.systemexec._
import org.openmole.tool.outputredirection.OutputRedirection
import scala.reflect.ClassTag
......
......@@ -21,11 +21,11 @@ import io.circe.jawn.{ decode, decodeFile }
import io.circe.syntax._
import monocle.macros.Lenses
import org.openmole.core.exception.InternalProcessingError
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.preference.Preference
import org.openmole.core.tools.service.Retry
import org.openmole.plugin.task.systemexec.{ ExecutionCommand, commandLine, execute, executeAll }
import org.openmole.tool.file._
import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.tool.stream._
import org.openmole.tool.stream.withClosable
......
......@@ -36,11 +36,11 @@ import org.openmole.plugin.task.udocker.DockerMetadata._
import org.openmole.tool.cache._
import org.openmole.core.dsl._
import org.openmole.core.fileservice.FileService
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.threadprovider._
import org.openmole.plugin.task.container.HostFiles
import org.openmole.tool.lock.LockKey
import org.openmole.plugin.task.container._
import org.openmole.tool.outputredirection.OutputRedirection
import scala.language.postfixOps
......
......@@ -9,13 +9,13 @@ import javax.servlet.http.HttpServletRequest
import org.json4s._
import org.json4s.jackson.JsonMethods._
import org.openmole.core.event._
import org.openmole.core.outputredirection.OutputRedirection
import org.openmole.core.project._
import org.openmole.core.workflow.execution.Environment
import org.openmole.core.workflow.mole.{ MoleExecution, MoleExecutionContext, MoleServices }
import org.openmole.core.dsl._
import org.openmole.rest.message._
import org.openmole.tool.collection._
import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.tool.stream._
import org.openmole.tool.tar.{ TarInputStream, TarOutputStream, _ }
import org.scalatra._
......
package org.openmole.tool.logger
/*
* Copyright (C) 2019 Romain Reuillon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import java.util.logging.Level
import org.openmole.tool.outputredirection._
import sourcecode._
object LoggerService {
def log(msg: String, level: Level = Level.INFO)(implicit loggerService: LoggerService, name: FullName, line: Line, outputRedirection: OutputRedirection) =
if (level.intValue() > loggerService.level.intValue()) {
OutputRedirection.println(s"""${name.value}:${line.value} - $msg""")
}
}
case class LoggerService(level: Level = Level.WARNING)
package org.openmole.core.outputredirection
package org.openmole.tool.outputredirection
object OutputRedirection {
implicit def fromPrintStream(s: java.io.PrintStream) = OutputRedirection(s)
def println(msg: String)(implicit outputRedirection: OutputRedirection) = outputRedirection.output.println(msg)
}
case class OutputRedirection(output: java.io.PrintStream = System.out)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment