Comments (13)
Progress! The encoder::Write
trait has been extended with a set_style
method, which can control the foreground and background colors as well as the foreground intensity of text it outputs. The console appender now colors text if attached to a tty/console. I've also added a new "highlight" formatter to the pattern syntax, which sets the color based on the log level. For example, the test crate now has the pattern {d} [{t}] {h({l})} {M}:{m}{n}
, which produces output that looks like this when it runs:
I copied the color selections from logback: intense red for error, red for warning, blue for info, and default for everything else.
I'd like to add a pattern formatter or group of them that lets you pick a specific style, but I'm not sure about the syntax right now.
from log4rs.
see #204 , its in progress but seems to be stalled
from log4rs.
Hi! I started using log4s and not seeing any colors in the terminal (I see them e.g. with pretty_env_logger
). Do I have to enable it somewhere?
from log4rs.
@Creative-Difficulty you may want to try using the formatter {h}
documented in the log4rs::encode::pattern
, i.e., here.
As an example, you could use this in your yaml_config:
appenders:
# An appender named "stdout" that writes to stdout
stdout:
kind: console
target: stdout
encoder:
pattern: " {h({l:<5}} {M} > {m}{n}"
# Set the default logging level to "warn" and attach the "stdout" appender to the root
root:
level: info
appenders:
- stdout
This should look somewhat similar to the output produced by the pretty_env_logger
crate, although not with its neat alignment.
from log4rs.
Yep, definitely seems reasonable to implement! I will probably not have a ton of time to work on it, but if you were willing to that'd be great.
from log4rs.
I really like this library but I needed colorization, so I went ahead and hacked in super basic, super dirty functionality. No config or anything, just hard-coded colour values for different log levels. I wrote it for my own use until someone smarter than me found the time to implement a proper solution, but I figured I'd post it here in case it helps. If nobody else finds the time to work on this functionality I might look into cleaning up the code and doing it right.
from log4rs.
To be fair, I haven't found much time to work on this. Thanks for working on it !
As a comparison this is the default in log4js:
With your solution, it currently looks like this:
In my opinion, this is already a big improvement !
If you're willing to write a cleaner solution for it, feel free to do so.
from log4rs.
Is anyone still working on this? If not, I am willing to pick it up.
I will need some pointers on how one would configure this in the .toml file
from log4rs.
I don't think anyone's working on it right now. Logback's pattern syntax might be a place to look for configuration syntax inspiration: http://logback.qos.ch/manual/layouts.html#coloring
from log4rs.
I've started working on this.
from log4rs.
I've released v0.4.3 with color support. All that the pattern encoder supports right now is level-based styling. I've opened a new issue to figure out syntax for configuration of specific styles: #17
from log4rs.
What's keeping it stalled currently?
from log4rs.
Is there any progress at all @estk ?
from log4rs.
Related Issues (20)
- will log4rs support zeromq appender?
- Support for KafkaAppender HOT 1
- Abbility to change case/word for logs
- Example for setting up log rotation HOT 1
- Prevent log4rs from creating $ENV{HOME} folders everywhere HOT 4
- c
- Real ip in the logs HOT 1
- Using custom appenders needs more documentation HOT 4
- Feature request logger filter
- Support for Key-Value Pairs HOT 1
- Redirect to a custom function using a custom appender
- Investigate and Resolve issues with Raw Config Deserializer HOT 1
- [bug] wrong thread id in linux HOT 6
- Publish on crates.io HOT 2
- Do you use any optimisations to log in file?
- README out of date with the 1.0 version HOT 2
- Clippy fails with log4rs HOT 2
- Resolve Deprecated Chrono API
- Refactor COLOR_MODE to OnceCell
- Increase test coverage across all modules HOT 1
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 log4rs.