[Snippet] [devHelper] Logger

2 482 Views No Comments 2 years ago
  • Here it is; the humble hunchback of the debugger: LOGGER.

    Logger is a simple class object, which brings depth to debugging.
    You can follow execution paths and trace bugs with precision.

    Installation: Simply copy and paste the snippet to your project! Just make sure Logger and its functions are defined before they are used.

    * Logger:log() – Normal log, as long as logger level is set to [All].
    * Logger:warn() – Warning log, as long as logger level is set to [All] or [Errors & Warnings].
    * Logger:error() – Error log.
    * Logger:enter() – Enter new scope. Will be added to the scope-path when logging messages.
    * Logger:exit() – Exit the current scope. Will remove the latest entry from the scope-path.

    Rest of the functions are for Logger’s internal use only.


    -- normal log msg
    Logger:log('we are in Main, and this only shows when we log All')
    -- normal log msg with color
    Logger:log('logger supports colors as well', Green)
    function doSomething()
         -- enter new scope
        -- log a warning
        Logger:warn('this time we warn something at Main::doSomething')
        -- exit current scope
    -- log an error
    Logger:error('execution stops here')
    • This topic was modified 2 years ago by pshai.
    HaasScript Code
    Sign in or Register to download for free
  • Earn Up to 2,000 $BMEX Tokens Promotion Type: contest Expires: July 31, 2023 Exclusive
    Fire up your trade bots and earn up to 2,000 $BMEX, $BTC, free subscriptions, and more.
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free