Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
雷东升
committed
Dec 29, 2017
1 parent
0df9414
commit 259e45f
Showing
3 changed files
with
18 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
use html::Context; | ||
use super::{Level}; | ||
|
||
pub trait ConsoleService { | ||
fn console_log(&mut self, message: &str); | ||
fn console(&mut self, level: Level, message: &str); | ||
} | ||
|
||
impl<MSG: 'static> ConsoleService for Context<MSG> { | ||
fn console_log(&mut self, message: &str) { | ||
js! { console.log(@{message}); } | ||
fn console(&mut self, level: Level, message: &str) { | ||
match level { | ||
Level::Log => { js! { console.log(@{message}); } }, | ||
Level::Warn => { js! { console.warn(@{message}); } }, | ||
Level::Error => { js! { console.error(@{message}); } }, | ||
_ => { println!("unknown Level."); }, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters