GithubHelp home page GithubHelp logo

geminilogging's Introduction

##GeminiLogging

A logging library for Apollo.

###GeminiLogging Methods

  • GetLogger - returns a logger object
    • Requires an options table:
      • level - Most detailed level of log to display, see below

      • pattern - Output pattern using the following substitutions:

        • %d - Date
        • %l - Error Level
        • %c - Function Name
        • %n - Line Number
        • %m - Message Passed to Error function
      • appender - Destination for Error message output examples:

        • GeminiConsole - Outputs to GeminiConsole if present, Print otherwise
        • blank - Print Function
        • custom function - function takes 3 vars: self, message, level

###Logger Methods

All loggers accept either a table that will be outputted or a string.format string and arguments.

  • debug - Generates a DEBUG level message

  • info - Generates a INFO level message

  • warn - Generates a WARN level message

  • error - Generates a ERROR level message

  • fatal - Generates a FATAL level message

  • SetLevel - Can be used to dynamically change the log display level. Example:

    • lua glog:SetLevel("WARN")

###Logging Levels:

The following levels are available:

Level Description
DEBUG Fine-grained informational events that are most useful to debug an application
INFO Informational messages that highlight the progress of the application at coarse-grained level
WARN Potentially harmful situations
ERROR Error events that might still allow the application to continue running
FATAL Designates very severe error events that will presumably lead the application to abort

###Example Usage:

local glog

function MyAddon:OnLoad()
	local GeminiLogging = Apollo.GetPackage("Gemini:Logging-1.2").tPackage
	glog = GeminiLogging:GetLogger({
        level = GeminiLogging.FATAL,
        pattern = "%d %n %c %l - %m",
        appender = "GeminiConsole"
    })
end

function MyAddon:DoFoo(strBaz, nBar, tBat)
	glog:debug("Baz: %s; Bar: %d", strBaz, nBar)  -- Not shown due to logging level
	glog:info(tBat)                               -- Not shown due to logging level

	glog:fatal("You'll see this one! Baz: %s", strBaz)
	glog:fatal(tBat)
	...
end

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.