jokade / slogging Goto Github PK
View Code? Open in Web Editor NEWA Typesafe-logging (and slf4j) compatible logging library based on macros for Scala/JVM, Scala.js, and Scala Native
License: MIT License
A Typesafe-logging (and slf4j) compatible logging library based on macros for Scala/JVM, Scala.js, and Scala Native
License: MIT License
This may force a logging model into scalajs that is not so common. Can this be factored out?
Implement a LoggingFactory that supports logging to more than one backend (possibly with filters).
Allow to specify which log levels should be omitted at compile time
Looks like nothing here at the moment:
http://central.maven.org/maven2/biz/enef/slogging_sjs0.6_2.12/0.5.3/
Add LoggerTemplate
with implementations for error
, warn
, info
, debug
and trace
, leaving only logMessage
to be implemented (based on #18)
If possible, reduce the size impact of ConsoleLoggerFactory on ScalaJS optimized code
Load winston logger via require("winston")
when scalaJSModuleKind := ModuleKind.CommonJSModule
is set in build.sbt
Please publish artifacts for the latest Scala 2.13.0, it should be rather straightforward to update.
Hi,
Here is how it is possible to collapse TRACE logs, perhaps using something like this : https://mariusschulz.com/blog/advanced-javascript-logging-using-console-group
Is it possible to do the same with slogger ?
For me a trace looks like this :
But it would be much nicer to have these "TRACE"-s already folded by default , like this :
PrintStream
to be used for each levelMessageFormatter
Hello. Im having trouble using PrintLogger in a clean project as it does not have a field printTimestamp
for some reason.
My build.sbt:
name := "loggingtest"
version := "0.1"
scalaVersion := "2.12.4"
libraryDependencies += "biz.enef" %% "slogging" % "0.6.1"
Main.scala:
import slogging._
object Main {
def main(args: Array[String]): Unit = {
LoggerConfig.factory = PrintLoggerFactory()
LoggerConfig.level = LogLevel.TRACE
PrintLogger.printTimestamp = true
}
}
Can you please point me to the right direction? Maybe there is some conflict of versions in maven repository or something?
Sorry for a basic question, I dont really have a lot of experience with Scala environment and I can't figure out what might be the problem.
Log the current timestamp if PrintLogger.printTimestamp==true
Instead of storing the logging source name in the logger instance this should be added as member to the LoggerHolder
trait. This way we don't need to generate a logger instance for every LoggingHolder, and we can re-use logger instances in FilterLogger.filter
functions.
val obj = json(x = 5)
logger.info(s"obj 1",obj) // not printing obj in console
dom.window.console.log(s"obj 2 ",obj) // working fine
Implement a Scala.js backend that sends the log messages via HTTP to a web server
I don't see a mention of this in the documentation.
The logger
methods don't take their msg
param by-name, but I guess the macro implementations may be providing that "laziness" to the msg-construction.
If I have a complicated interpolated string, I don't want to create it unless I am actually going to log itβ¦
A FilterLogger uses a PartialFunction that receives the name of the logging source and the LogLevel, and returns the logger instance to be used to log the message.
Even if SN 0.4.0-M2 is a milestone, it is quite stable and now used as a target for several projects.
It would thus be great to consider to release a version of slogging compatible with this Scala Native version.
Thanks.
the following
private def getTimestamp = new Date().toString
produces output
Date(1521735026318)
was this the intent?
It currently uses text/html
but should probably use application/json
I'll prepare a PR if this is the desired behaviour
Provide a macro flag to omit logging code altogether:
-Xmacro-settings:slogging.disable
Provide a TerminalLogger
with colored terminal output for scala-native
Currently, calling LoggerFactory.apply()
assigns the LoggerFactory on which the call was made to LoggerConfig.factory
. We need to remove this side effect in order to be able to build LoggerFactoryS that use other factories (e.g. a FilterLoggerFactory).
New semantics: calling LoggerFactory.apply()
simply returns the default instance to be used; factories need to be assigned explicitly, i.e.:
LoggerConfig.factory = PrintLoggerFactory()
The issue appears to be in the slogging-winston:
val winston = Dynamic.global.require("winston")
Under webpack, winston will not load under the global variable.
Support logging configuration using HOCON (Typesafe config of shocon)
The default logger defaults to NullLogger right now. We have backend code that uses slf4j and need a simple way to configure the SLF4JLoggerFactory backend when running in the JVM. This isn't as simple as putting a configuration point in a single place where our application starts. There are numerous other scenarios where we may not go through that entry point but still need our backend code to use the SLF4JLoggerFactory (unit tests, integ tests, console, dev main vs prod main, etc.)
We'd like to configure the slogging backend in a manner similar to what is done to configure Akka to use the slf4j logging backend which is to put an entry in our application.conf like:
slogging.backend = "slogging.SLF4JLoggerFactory"
Unfortunately that would mean that your slogging core would have to take a dependency on TypesafeConfig which probably isn't doable.
An alternative is to allow jvm args: -Dslogging.backend=slogging.SLF4JLoggerFactory
For use with Scala.js we should have a LazyLoggingJS
trait extending js.Object
so that it can be mixed into classes marked as @ScalaJSDefined
.
The release notes say:
Version 0.6.2 (17.09.20)
Published for Scala 2.12.x/2.13.x, Scala.js 1.0, and Scala Native 0.3.9/0.4.0-M2.
but I can't find the 2.12 version: https://mvnrepository.com/artifact/biz.enef/slogging-slf4j
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.