chadlrnsn / pretty-log

A tiny logging module for Garrys mod Lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

log.lua

A tiny logging module for Lua.

ss

Installation

Important

You should initialize like this

hook.Add("Initialize", "InitLogs", function()
    // your stuff here
end)

The lua/autorun/log.lua file should be dropped into an garrysmod/addons/

git clone https://github.com/chadlrnsn/pretty-log.git

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(...)

Example

local s = function(s, ss)
    local result = s+ss
    log.trace(result)
    log.debug(result)
    log.info(result)
    log.warn(result)
    log.error(result)
    log.fatal(result)
end

s(33, 2)

Output

Output

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.

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.

About

A tiny logging module for Garrys mod Lua

License:MIT License


Languages

Language:Lua 100.0%