Comments (14)
Seems fine :)
from scribe.
That did it, thanks!
from scribe.
Also, as another (but much harder to reproduce) datapoint, my tooling captures STDERR from a node process which Scribe logs to, and I get this:
Do you know what those %c
symbols are? I couldn't reproduce in a standalone node run.
from scribe.
The Scala.js support was originally specifically focused on browser output. Try this to see if it fixes your problems:
Logger.root.clearHandlers().withHandler(outputFormat = ANSIOutputFormat).replace()
The problem is this: https://github.com/outr/scribe/blob/master/core/js/src/main/scala/scribe/Platform.scala#L20
Which uses: https://github.com/outr/scribe/blob/master/core/js/src/main/scala/scribe/output/format/RichBrowserOutputFormat.scala that is specifically designed for rich output to the browser console. If we can add detection of browser vs Nodes.js, then we can differentiate which output style to use automatically.
Let me know if the code above fixes it and we can work toward a patch to make it automatic.
from scribe.
Let me know if the code above fixes it and we can work toward a patch to make it automatic.
This worked, thank you!
that is specifically designed for rich output to the browser console
nice, I had no idea %c
existed and that it applies CSS
from scribe.
Now, we just have to come up with a way to differentiate between running in the browser and running in Node.js. Any ideas? :)
from scribe.
I would suggest using the hack outlined in detect-node package: https://github.com/iliakan/detect-node/blob/master/index.js#L2
I actually mentioned it in the original issue :)
basically if there's a global process
object, then it's a Node.js environment (it seems)
Things actually get hairier because there's now at least Deno and Bun runtimes as well, but I think both are marginal in comparison to Node.js
from scribe.
@armanbilge linked to one already in use: https://github.com/http4s/http4s-crypto/blob/a04b435d8e06c907bdcc2233b61c43ffa41a3ccb/crypto/js/src/main/scala/org/http4s/crypto/facade/package.scala#L24-L27
from scribe.
Thanks, I'll take a look when I have a chance or feel free to submit a PR.
from scribe.
Is this a reasonable test to validate the availability of ANSI in Node.js?
sys.env.contains("TERM")
It's what I use on JVM and Native, but I'm not sure if the environment stuff all works the same within Node.js?
from scribe.
No, sys.env
does not work in Scala.js, even on Node.js. You'd have to use process.env
.
from scribe.
@armanbilge nice, thanks!
How's this look?
private def processEnv: Dictionary[Any] = Try(js.Dynamic.global.process.env.asInstanceOf[js.Dictionary[Any]])
.getOrElse(js.Dictionary.empty)
override def env(key: String): Option[String] = processEnv.get(key).map(_.toString)
from scribe.
I've created this PR: #384
Feel free to make any suggested changes before I merge and release.
from scribe.
Release 3.10.7
includes the fix for this. @keynmol can you please verify this automatically works now before you close this ticket? Thanks!
from scribe.
Related Issues (20)
- Unable to have minimumLevel=Info and only enable Trace for certain packages HOT 11
- Overriding the path for log files HOT 4
- Help: configure stdout/stderr in function of LogLevel HOT 15
- Compare perfomance with Chronicle-Logger HOT 2
- NPE when logging with SLF4J and Throwble == null HOT 4
- Different versions of scala-collection-compat pulled in transitively HOT 3
- Logger ignores `data` field HOT 3
- AsynchronousLogHandle shutdown hook HOT 3
- MDC syntax improvement HOT 7
- Standardize JSON output ? HOT 3
- Is it safe to use MDC with cats-effect? HOT 5
- Logging stderr HOT 2
- ScribeCirceJsonSupport does not output stack traces for Exceptions HOT 2
- Minimal example for JSON logging: Is this okay? HOT 2
- Allow scribe.fatal HOT 2
- FormatBlock.Date.ISO8601 does not take offset into account HOT 12
- `scribe-slf4j` does not support `slf4j-api` 2.x and `scribe-slf4j18` does not exist HOT 4
- How to integrate with scala-play HOT 3
- Error on cross linking with scala 2.12.19
- Bump scala-collection-compat dependency to 2.12.0 (fix Scala Native 0.5 support) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scribe.