]> git.puffer.fish Git - matthieu/frr.git/commit
lib: allow exporting all logging functions to Lua
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 9 Aug 2019 20:13:07 +0000 (20:13 +0000)
committerQuentin Young <qlyoung@nvidia.com>
Tue, 1 Dec 2020 23:37:14 +0000 (18:37 -0500)
commitd473bdc7f1e65a37384acb29af568c4b12a5a207
treedb53e564149e4b313a5954fb9d0465926959ca2f
parentcd6ca660c5e96f14f50b6a2f4f6f5cd83cb70d13
lib: allow exporting all logging functions to Lua

Add a function that will export FRR's logging functions into a Lua
table, and add that table to the table of your choice (usually _ENV).

For instance, to add logging to the global environment:

  lua_gettable(L, LUA_REGISTRYINDEX);
  lua_gettable(L, LUA_RIDX_GLOBALS);
  frrlua_export_logging(L);

Then the following functions are globally accessible to any Lua scripts
running with state L:

  - log.debug()
  - log.info()
  - log.notice()
  - log.warn()
  - log.error()

These are bound to zlog_debug, zlog_info, etc. They only take one string
argument for now but this shouldn't be an issue given Lua's builtin
facilities for formatting strings.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/frrlua.c
lib/frrlua.h