The definitive source of the best
JavaScript libraries, frameworks, and plugins.

  • ×

    Message and Error logger implementation
    Filed under  › 

    • 🔾3%Overall
    • 30
    • 153.8 days
    • 🕩4
    • 👥1


    Hermes.js. Highly extensible message/error handler system.



    Hermes definition in Wikipedia:

    "Hermes is the great messenger of the gods in Greek mythology and a guide to the Underworld"

    Hermes will log all the messages for you. Defer or send your logs immediately. Different defined message types:

    • ALL
    • DEBUG
    • INFO
    • TRACE
    • ERROR
    • FATAL

    And if you have some error you can add (or add it by the system if it's an uncaugh error) info about the file (filename or filename Url) and the line number where the error is logged.

    Another important things:

    • You can create your own errors or messages
    • You can create your own layouts
    • You can create your own appenders
    • You can create your own levels

    Hermes is an error handler that allows you to create your own log appenders extending the Appender abstract class and define your log and clear methods.

    Examples to see for yourself!


    Before using it:

    Insert in your code:

    <script type="text/javascript" src="/path/to/your/js/libs/Hermes.js"></script>

    Add Message:

    If Immediate mode is active the message will be logged immediately.

    Hermes.logger.addMessage( new Hermes.message( Hermes.level.DEBUG, "Category", "Message", "", "" ) );

    Log Error:

    Hermes will try to log all the deferred and pending errors.


    Force Log:

    Hermes will log all the deferred and pending error.


    Create a new Message/Error

    var NewError = function(sFilenameUrl, nLineNumber)
        Hermes.message.apply(this, [Level.INFO, 'New Error or message', 'The error or message', sFilenameUrl, nLineNumber, sDateFormat]);
    NewError.prototype = new Hermes.message();

    Create a new Layout

    var NewLayout = function()
        Hermes.layout.apply(this, arguments);
    NewLayout.prototype = new Hermes.layout();
    NewLayout.prototype.format = function(oMessage)
        //Your implementation must be here

    Create a new Appender

    var NewAppender = function(oLevel, sCategory, sMessage, sFilenameUrl, nLineNumber, sDateFormat)
        Hermes.appender.apply(this, arguments);
        this.oLayout = new NewLayout();
    NewAppender.prototype = new Hermes.appender();
    NewAppender.prototype.log = function(oError)
        //Your implementation must be here
    NewAppender.prototype.clear = function(oError)
        //Your implementation must be here


    Examples from cloned repo to see for yourself!

    Examples to see for yourself!


    Hermes.js is licensed under the MIT license.


    Hermes.js was inspired by Log4Js.

    Show All