Logger is a lightweight pure Javascript library, it helps for Get the all console logs into browser screen window without opening console/developer mode
v1.0.1
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>Logger.js works on most all kind of browsers latest versions.
- Google Chrome
- Firefox
- Safari
- IE
- Opera
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");
});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.
logger.on();Show the logger screen window if is turned off.
logger.off();Hide the displaying logger screen window.
logger.kill();Destroy the logger screen window if it's created.
logger.position({'direction':'bottom_right'});Change the logger screen window position.
logger.log('foo');For general output of logging information. You may use string substitution and additional arguments with this method.
logger.warn("foo");Outputs a warning message. You may use string substitution and additional arguments with this method
logger.error('Opps.. Error');Outputs an error message. You may use string substitution and additional arguments with this method.
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.
logger.dirxml(object);Displays an XML/HTML Element representation of the specified object if possible or the JavaScript Object view if it is not
logger.group(object);Creates a new inline group, indenting all following output by another level. To move back out a level, call groupEnd().
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().
logger.groupEnd();Exits the current inline group.
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.
logger.profileEnd();Stops the profiler. You can see the resulting profile in the browser's performance tool
logger.table(object);Displays tabular data as a table.
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.
logger.timeEnd(label);Stops the specified timer and logs the elapsed time in seconds since its start.
logger.timeStamp(label);Adds a marker to the browser's Timeline or Waterfall tool.
logger.trace(object);Outputs a stack trace.
logger.assert(expression, object);Log a message and stack trace to console if first argument is false.
logger.count(label);Log the number of times this line has been called with the given label.
logger.debug(object);Writes a message to the console, including a hyperlink to the line where it was called.
logger.exception(object);Prints an error message together with an interactive stack trace of JavaScript execution at the point where the exception occurred.object
logger.clear();Clears the console.
And of course ksankumar itself is open source with a [public repository][ksankumar] on GitHub.
Copyright (c) 2016 Santhosh Kumar Krishnan Licensed under the MIT license.
