https://github.com/notafile/tinylualogger
Simple single file Lua logging module. Could have been a gist really, but that would have been harder for me to find again.
https://github.com/notafile/tinylualogger
Last synced: 3 months ago
JSON representation
Simple single file Lua logging module. Could have been a gist really, but that would have been harder for me to find again.
- Host: GitHub
- URL: https://github.com/notafile/tinylualogger
- Owner: NotAFile
- License: mit
- Created: 2016-07-01T21:53:02.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-01T22:19:21.000Z (about 10 years ago)
- Last Synced: 2025-01-16T19:23:05.904Z (over 1 year ago)
- Language: Lua
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinylualogger
Simple single file Lua logging module. Could have been a gist really, but that would have been harder for me to find again.
##Usage
Just `require("logging")` in all files that require logging.
To change the default logging level from `INFO` to something else, call `logging.set_default_loglevel(loglevel)` directly after `require("logging")`, where `loglevel` is one of `logging.loglevels`.
To log, you must first create a logger:
local logger = logging.logger.new(loggername)
Where `loggername` is the name of the logger. To use the name of the current module as a name (recommended), pass `...`. If not given, the logger name defaults to `root`
After that, you can use the logger as expected:
logger.debug("debug message") -- DEBUG:root: debug message
logger.info("info message") -- INFO:root: info message
logger.warn("warning message") -- WARN:root: warning message
logger.error("error message") -- ERROR:root: error message
logger.critical("critical error message") -- CRITICAL:root: critical error message
To change the logging level for this file only, use `logger.set_loglevel(loglevel)` in similar fashion to `logging.set_default_loglevel(loglevel)`
see `tests/` for an example project (it's a bit preposterous of me to call them tests)