Reputation: 6727
I'm using Lua from OpenWRT based Access Point device to develop some S/W on it.
I want to find a good logging libraries for Lua. Do you have any recommendation? I checked about lsyslog.
Upvotes: 2
Views: 7539
Reputation: 11
On OpenWRT, there is lua-posix library as a package. Then you could use posix.syslog http://luaposix.github.io/luaposix/modules/posix.syslog.html.
Upvotes: 0
Reputation: 258
A tiny little one: https://github.com/rxi/log.lua
Usage:
local log = require "log"
log.trace(...)
log.debug(...)
log.info(...)
log.warn(...)
log.error(...)
log.fatal(...)
Upvotes: 3
Reputation: 11
Old topic, I know.
There is another way to skin the syslog: luaposix
, package already in OpenWRT (at least 15.05.1). Using luaposix
, your code could be as short as:
log = require("posix.syslog")
log.syslog(log.LOG_INFO, "Hello, world!")
Upvotes: 1
Reputation: 543
How fancy do you want the logging? Lua on Openwrt has the nixio library. It provides syslog access with openlog(), syslog(), closelog(). nixio
Upvotes: 2
Reputation: 6727
I found that lsyslog is good enough for OpenWRT.
http://luaforge.net/projects/lsyslog/
I can build it from OpenWRT by using the below feeds Makefile.
include $(TOPDIR)/rules.mk
PKG_NAME:=lsyslog
PKG_VERSION:=5
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://files.luaforge.net/releases/lsyslog/lsyslog/lsyslog-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/lsyslog
SUBMENU:=Lua
SECTION:=lang
CATEGORY:=Languages
TITLE:=lsyslog
URL:=http://luaforge.net/projects/lsyslog/
DEPENDS:=+lua
endef
define Package/lsyslog/description
lsyslog is simple binding API from Lua to syslog.
endef
define Build/Configure
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/ \
LIBDIR="$(TARGET_LDFLAGS)" \
CC="$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -std=gnu99 -fPIC" \
LD="$(TARGET_CROSS)ld -shared" \
so
endef
define Package/lsyslog/install
$(INSTALL_DIR) $(1)/usr/lib/lua
$(INSTALL_BIN) $(PKG_BUILD_DIR)/syslog.so $(1)/usr/lib/lua
endef
$(eval $(call BuildPackage,lsyslog))
Upvotes: 1