Giter VIP home page Giter VIP logo

log.lua's Introduction

log.lua

A tiny logging module for Lua.

screenshot from 2014-07-04 19 55 55

Installation

The log.lua file should be dropped into an existing project and required by it.

log = require "log"

Usage

log.lua provides 6 functions, each function takes all its arguments, concatenates them into a string then outputs the string to the console and -- if one is set -- the log file:

  • log.trace(...)
  • log.debug(...)
  • log.info(...)
  • log.warn(...)
  • log.error(...)
  • log.fatal(...)

Additional options

log.lua provides variables for setting additional options:

log.usecolor

Whether colors should be used when outputting to the console, this is true by default. If you're using a console which does not support ANSI color escape codes then this should be disabled.

log.outfile

The name of the file where the log should be written, log files do not contain ANSI colors and always use the full date rather than just the time. By default log.outfile is nil (no log file is used). If a file which does not exist is set as the log.outfile then it is created on the first message logged. If the file already exists it is appended to.

log.level

The minimum level to log, any logging function called with a lower level than the log.level is ignored and no text is outputted or written. By default this value is set to "trace", the lowest log level, such that no log messages are ignored.

The level of each log mode, starting with the lowest log level is as follows: "trace" "debug" "info" "warn" "error" "fatal"

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.

log.lua's People

Contributors

rxi avatar

Watchers

 avatar  avatar

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.