This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Implement an easily replaceable Printer for console
#551
Labels
API
builtins
PRs and Issues related to builtins/intrinsics
discussion
Issues needing more discussion
enhancement
New feature or request
Current situation
We currently have the
Console
standard implemented, but we don't implement it with the commonLogger
,Printer
andFormatter
operations. This prevents crates using Boa from creating their own printers that will for example not print anything but save the result to a file or a database.Proposed feature
We should implement an easily replaceable
Printer
that would either be passed to the Realm / Interpreter, so that by default, theconsole
will work as it does now, but we should have a way of creating theconsole
object to use a customPrinter
.How do we do this?
We should have a
printer
object that implements thePrinter
trait, which would be something like:Maybe the trait needs to be modified, and we would need a
LogLevel
enum, but I think the implementation should go in this direction. The idea behind having the logger use&mut self
is because we might want a printer that stores the logs in memory, or in a buffer, or that usesWrite
to write to a log file.What I'm not very sure is on what the
options
should be in thePrinter
. Maybe we can just skip that argument for now.The text was updated successfully, but these errors were encountered: