4
Apr

Firebug: logging features

categories Computer, Tutorials    

Many developers think of Firebug as the mother of all web tools. There’s a reason for it, because Firebug contains sophisticated tools to do nearly everything you need being a web developer, starting with little css experiments, debugging complex jscript-applications, profiling of web pages and many more.

Not commonly known is how to create your own logs using JScript.

For example, …

console.log('Hello World!');

prints exactly this in your Firebug console.

You can refine this, since most of you distinguish informations, warnings, errors and debug output.

console.debug('Debug');
console.info('Information');
console.warn('Warning');
console.error('Error');

Debugging variables can be helped, too.

var banana = 1.234;
var orange = "Test";
console.log("my %a has the value %d", orange, banana);

If you have the need to group log output, just do it like this:

console.group('myGroup');
    console.info('Info1');
    console.debug('What did I want to know?');
console.groupEnd();

Even more features, p.e. timing values, stacks and so on, are documented here.

By the way:
Most of these features have already found their way into the debugger used by Google Chrome!

Kommentare

Leave a comment!