Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an easily replaceable Printer for console #551

Closed
Razican opened this issue Jul 8, 2020 · 0 comments
Closed

Implement an easily replaceable Printer for console #551

Razican opened this issue Jul 8, 2020 · 0 comments
Labels
API builtins PRs and Issues related to builtins/intrinsics discussion Issues needing more discussion enhancement New feature or request

Comments

@Razican
Copy link
Member

Razican commented Jul 8, 2020

Current situation
We currently have the Console standard implemented, but we don't implement it with the common Logger, Printer and Formatter 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, the console will work as it does now, but we should have a way of creating the console object to use a custom Printer.

How do we do this?
We should have a printer object that implements the Printer trait, which would be something like:

trait Printer {
    fn print(&mut self, logLevel: LogLevel, args: &[Value]);
}

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 uses Write to write to a log file.

What I'm not very sure is on what the options should be in the Printer. Maybe we can just skip that argument for now.

@Razican Razican added enhancement New feature or request discussion Issues needing more discussion builtins PRs and Issues related to builtins/intrinsics API labels Jul 8, 2020
@Razican Razican changed the title Implement an easily replaceable Logger, Printer and Formatter for console Implement an easily replaceable Printer for console Jul 8, 2020
@boa-dev boa-dev locked and limited conversation to collaborators Aug 29, 2021
@Razican Razican closed this as completed Aug 29, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
API builtins PRs and Issues related to builtins/intrinsics discussion Issues needing more discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant