@George_Sgouros wrote:
Hi everybody
I am new to Ember and Javascript (I do have a C++, Java, Rails background)
I often use console.log() from my code (route, component, controller JS files) to post helpful messages to Chrome console.
After finding out that I can use custom console stylesheets in Chrome to improve readability of my messages (see here) I now often log like this:
// inside my-component.js console.log('%cMy function is called', 'color: green; font-size: large');
What I am after, is to make a simple JS class (or any other appropriate JS entity for that matter) with logging functions (log, info, error etc) which apply the styles automatically.
Ideally, I would like to log like this:
// inside my-component.js // somehow import my pretty-logging code myConsole.log('My function is called); // this should print the message in chrome console in green and with large font
So here is my JS and Ember question wrapup:
- Should I somehow extend the built-in console ember object with functions like console.mylog, console.myInfo etc?
- Would it be a better idea to somehow override the built-in Ember console functions and add styles of my own?
- WHERE should I put the new code/overrides? Where does Ember expect my code and how do I import it to the rest of my code?
- Will logging from .hbs files be possible by the way you might suggest?
I know these questions are a bit generic, however please note that my purpose here is NOT to get a snippet or a quick hack to solve the problem at hand. What I would rather know is the best approach for adding custom code to my Ember JS project the-Ember-way thus making me a better Ember programmer.
many thanks in advance
George
Posts: 3
Participants: 2