ComputerCraft Forums

ComputerCraft => Programs => APIs and Utilities => Topic started by: MineCommander on Feb 07, 2022, 06:54 AM

Title: log4cc - A simple log system for your program in console, file and rednet
Post by: MineCommander on Feb 07, 2022, 06:54 AM
Visit GitLab repository for more detailed information: https://gitlab.com/MineCommander/log4cc


A simple log system for your programs. Like those in real developing, it supports console and file logging. But it also supports send log messages via Rednet with wired/wireless modem, so that you can check if your mining turtle is working well from thouthands blocks away, or build a monitor center to watch all of your computers, etc.

How to use:

Download log4cc by running this:

wget run https://gitlab.com/-/snippets/2249573/raw/main/get_log4cc.lua
Then include the module:

local log4cc = require "lib.log4cc"
Use log4cc.info(), log4cc.warn(), log4cc.error() and log4cc.debug() to write log:

log4cc.info("Hello log4cc!")
You can also edit config to enable file and remote logging:

log4cc.config.file.enabled = true
log4cc.config.file.fileName = "log.txt" -- save log into log.txt
log4cc.config.remote.enabled = true
log4cc.config.remote.targetID = {3,5} -- let computer #3 and #5 receive log

Why log4cc:


Todo:

Why not Pastebin and GitHub:
These two websites are a little difficult to visit in China, so I choose pure GitLab deploying to improve the access speed.
Title: log4cc - A simple log system for your program in console, file and rednet
Post by: Erb3 on Feb 25, 2022, 03:28 PM
Worked good, but it would be cool if it used colors when it logged to a terminal.
For example:
[WARN] This is a warning
[ERROR] This is a error
[DEBUG] This is a debug