Git Product home page Git Product logo

apua's Introduction

Apua

Useful helper functions to make developing web apps a bit easier. Includes logging tools (with log levels, so don't worry about them showing in prod environment) and much more!

Usage

Place the apua.js in your document's <head> tag or just before the ending </body> tag before any other script files, that use apuaJS.

<script type="text/javascript" src="/path/to/apua.js"></script>

Log

apua.log() shows up as a regular log/debug line in browser console. Logs require logLevel: 1 for them to show up.

apua.log("I show up in browser console as a regular log!");

Todo

apua.todo() is a basic log/debug line in browser console with a little TODO string before the given message. Todos require logLevel: 2 or lower for them to show up.

apua.todo("I show up in browser console as a regular log with TODO text in front of me!");

Security

apua.security() messages show as a warning in browser console with SECURITY text before them. Security messages require logLevel: 3 or lower to show up.

apua.security("I show up in browser console as a warning with SECURITY text in front of me!");

Warn

apua.warn() messages show as a warning in browser console with WARNING text before them. Warnings require logLevel: 4 or lower to show up.

apua.warn("I show up in browser console as a warning with WARNING text in front of me!");

Error

apua.error() messages show as an error in browser console with ERROR text before them. Errors require logLevel: 5 or lower to show up.

apua.error("I show up in browser console as an error with ERROR text in front of me!");

Bug

apua.bug() messages show as an error in browser console with BUG text before them. Bugs require logLevel: 6 or lower to show up.

apua.bug("I show up in browser console as an error with BUG text in front of me!");

Fatal

apua.fatal() messages show as an error in browser console with FATAL text before them. Fatal errors require logLevel: 7 or lower to show up.

apua.fatal("I show up in browser console as an error with ERROR text in front of me!");

Assert

apua.assert(condition, message, openDebugger) are used to make sure a condition given to them returns true. You can specify a condition, an error message and whether or not you want it to open the browser debugger before continuing executing the code block or just straight up terminating processing the code. apua.assert needs devMode: true to execute.

Example of using apua.assert to open the browser debugger

apua.assert(foo == bar, "Foo does not equal bar", true);

Example of not using the debugger

apua.assert(1 == 2, "1 does not equal 2!");

Custom init

You can make a custom init of Apua by introducing a new variable that uses it or by overriding the default apua variable.

Example of a custom init

var apua = new apua({
    devMode: false,
    logLevel: 4
});

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.