log4cc - A simple log system for your program in console, file and rednet

Started by MineCommander, Feb 07, 2022, 06:54 AM

Previous topic - Next topic

MineCommander

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:

  • Written in pure ASCII Lua
  • Allow custom log format
  • Remote log send and receive(use rednet.receive(), or receiver program provided)
  • Load config from file
  • No JNDI security bugs

Todo:
  • Remote log encrypting
  • Async logging in multitask to reduce lag

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.

Erb3

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
It's not a data breach, it's a surprise backup.