Coder Social home page Coder Social logo

ajsoriar / purple-console Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 210 KB

Light javascript component to do logging stuff right to the WEB UI, without the need of developer tools. It can be useful when dealing with special hardware like mobile devices or TV's. Data can be rendered in a div, a canvas or a textarea. There is an API to set start points and LAPs in order to do benchmarking and print the results in the console. Several consoles can be launched and the look and feel can be personalised.

JavaScript 93.55% Go 6.45%
javascript-component console-tool benchmarking set-top-box smart-tv logging-library logging-js textarea

purple-console's Introduction

purple-console Build Status

npm version NuGet version

NPM

Javascript component that prints logs in a DIV layer. It can be useful when dealing with special hardware like Smart TVs or Set-Top Boxes that don't allow debugging.

purple-console initialization example

Live example: http://subidote.com/purple-console/

1 Quick start

1.1 Download and Install purple-console

2 Include dependences

yarn add purple-console
# or
npm install purple-console

2.1 In your HTML

<script src="./node_modules/purple-console/src/purple-console.js"></script>

2.2 In your js code

<script>
    ajsrConsole.log("Hello world!");
</script>

2.3 Extra examples ready to copy and paste

<script>
    ajsrConsole.filterJSErrors();
    ajsrConsole.setLogAlias("debug");
    ajsrConsole.setBgColor("rgba(0,0,150,1)");
    ajsrConsole.setBorderColor("rgba(0,255,255,1)");
    ajsrConsole.setTextColor("rgba(255,255,255,1)");
    ajsrConsole.toggleOpacity();
    ajsrConsole.printTime();
    debug("CONSOLE");
    ajsrConsole.printTime(false);
    ajsrConsole.move("UP");
    ajsrConsole.move("LEFT");
    ajsrConsole.move("RIGHT");
    ajsrConsole.autoHeight();
    ajsrConsole.useColors();
    debug("CONSOLE color1", "yellow");
    ajsrConsole.printTime();
    ajsrConsole.useColors(false);
    debug("CONSOLE color2", "yellow");
    ajsrConsole.toggleOpacity();
    ajsrConsole.setSize(400,500);
    ajsrConsole.error("ERROR");
    ajsrConsole.success("SUCCESS");
    var myObj = {
        "1": "a-11",
        "2": "a-11",
        "3": {
            "b1": "b-11",
            "b2": "b-11",
            "b3": "b-11",
        }
    };
    debug.printObj(myObj);
</script>

purple-console print example

3 Core functions

3.1 Printing on a div layer

By default all printing stuff will be done using one color

3.1 Printing text in color

ajsrConsole.usecolors();
ajsrConsole.debug("Message in color!", "yellow");

Some notes about colors

This console creates a div layer on every log operation when color mode is on. In some devices rendering more than 100 divs increases the response of the UI more and more til it becomes unmanageable. So you should reset the console from time to time.

ajsrConsole.cls(); //clear the console from time to time

Completely deactivate color

ajsrConsole.usecolors(false);

3.2 Change background color

ajsrConsole.setBgColor("rgba(0,0,150,1)");

3.3 Print JSON object

    var myObj = {
        "1": "a-11",
        "2": "a-11",
        "3": {
            "b1": "b-11",
            "b2": "b-11",
            "b3": "b-11",
        }
    };
    debug.printObj(myObj);

purple-console print js Object example

3.4 Set start points and LAPs

Used to do benchmarking and print the results in the console.

ajsrConsole.setLap("LAP TEXT!");

4 Complete list of available options

Methods Default Description
init - Resets the console to initila params.
log - Main functionality here.
cls - Clear the console.
resetColors - Go back to default colors.
setLogAlias - Use whatever instead of ajsrConsole.
setBgColor - Color of the background.
setBorderColor - Color of the border.
setTextColor - -
move DOWN & LEFT -
moveNext - -
autoHeight - Will toggle height from 33% and 66% of the available space.
setSize number -
toggleOpacity - Toggles opacity between 100% to 50%.
useColors false Allows the use of colors when doing log
printTime false -
setParams - -
startTime - -
setLap - -
printLaps - -
filterJSErrors false -
printObj - Prints a json object in a box. 1st param is a json. 2nd and 3rd (optional) are border and background colors.
write - -
error - -
success - -
setMaxObjLength 5 Increases the allowed print length.
br - Prints a blank line.
setPrintStrategy timeout 1, 2 delayed by timestamp or 3 delayed by timeout
hide - Hides the console.
show - Shows the console.
fontSize 11 Sets the font size.
preset - Sets a group of configuration options useful in my day by day work.

5 Development

5.1 Install node

https://nodejs.org/es/

5.2 Install grunt globally

sudo npm install --unsafe-perm=true --allow-root
sudo npm install -g grunt-cli

5.3 Build

grunt build

6 License

purple-console is MIT licensed.

Free Software, Yeah!

purple-console's People

Contributors

ajsoriar avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wanghongyan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.