/logger.js

Get all console logs into screen without opening console/developer mode.

Primary LanguageJavaScriptMIT LicenseMIT

Logger

Logger is a lightweight pure Javascript library, it helps for Get the all console logs into browser screen window without opening console/developer mode

Version

v1.0.1

Installation

You need Gulp installed globally:

$ npm i -g gulp
$ git clone https://github.com/ksankumar/logger.js
<script type="text/javascript" src="lib/logger.min.js"></script>

Screenshot

Browser Support

Logger.js works on most all kind of browsers latest versions.

  • Google Chrome
  • Firefox
  • Safari
  • IE
  • Opera

Logger.js API

ready

If you want to render logger if before DOM ready or within , use this API

logger.ready(function(l) {
    l.log("logger.log");
    l.info("logger.info");
});

init

If you want to render loggerwithin , use this API

logger.init({'bgColor':'tomato', 'direction':'top_right'});
  • options
    • directions - positions for logger window (top_left/top_right/bottom_left/bottom_right)
    • bgColor - background color

Initializing the logger screen window.

On

logger.on();

Show the logger screen window if is turned off.

Off

logger.off();

Hide the displaying logger screen window.

kill

logger.kill();

Destroy the logger screen window if it's created.

Position

logger.position({'direction':'bottom_right'});

Change the logger screen window position.

log

logger.log('foo');

For general output of logging information. You may use string substitution and additional arguments with this method.

warn

logger.warn("foo");

Outputs a warning message. You may use string substitution and additional arguments with this method

error

logger.error('Opps.. Error');

Outputs an error message. You may use string substitution and additional arguments with this method.

dir

logger.dir(object);

Displays an interactive listing of the properties of a specified JavaScript object. This listing lets you use disclosure triangles to examine the contents of child objects.

dirxml

logger.dirxml(object);

Displays an XML/HTML Element representation of the specified object if possible or the JavaScript Object view if it is not

group

logger.group(object);

Creates a new inline group, indenting all following output by another level. To move back out a level, call groupEnd().

groupCollapsed

logger.groupCollapsed(object);

Creates a new inline group, indenting all following output by another level; unlike group(), this starts with the inline group collapsed, requiring the use of a disclosure button to expand it. To move back out a level, call groupEnd().

groupEnd

logger.groupEnd();

Exits the current inline group.

profile

logger.profile(label);

Starts the browser's build-in profiler (for example, the Firefox performance tool). You can specify an optional name for the profile.

profileEnd

 logger.profileEnd();

Stops the profiler. You can see the resulting profile in the browser's performance tool

table

logger.table(object);

Displays tabular data as a table.

time

logger.time(label);

Starts a timer with a name specified as an input parameter. Up to 10,000 simultaneous timers can run on a given page.

timeEnd

logger.timeEnd(label);

Stops the specified timer and logs the elapsed time in seconds since its start.

timeStamp

logger.timeStamp(label);

Adds a marker to the browser's Timeline or Waterfall tool.

trace

logger.trace(object);

Outputs a stack trace.

assert

logger.assert(expression, object);

Log a message and stack trace to console if first argument is false.

count

logger.count(label);

Log the number of times this line has been called with the given label.

debug

logger.debug(object);

Writes a message to the console, including a hyperlink to the line where it was called.

exception

logger.exception(object);

Prints an error message together with an interactive stack trace of JavaScript execution at the point where the exception occurred.object

clear

logger.clear();

Clears the console.

About

And of course ksankumar itself is open source with a [public repository][ksankumar] on GitHub.

Reference

Firefox Console API

Chrome Console API

License

Copyright (c) 2016 Santhosh Kumar Krishnan Licensed under the MIT license.