• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 22550237931

01 Mar 2026 06:56PM UTC coverage: 64.812% (-8.9%) from 73.687%
22550237931

Pull #14920

github

web-flow
Merge e05854a6d into 90823fa90
Pull Request #14920: draft: rust based configuration file parser and loader - v4

561 of 789 new or added lines in 4 files covered. (71.1%)

23225 existing lines in 498 files now uncovered.

131605 of 203055 relevant lines covered (64.81%)

2328818.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/util-lua-log.c
1
/* Copyright (C) 2025 Open Information Security Foundation
2
 *
3
 * You can copy, redistribute or modify this Program under the terms of
4
 * the GNU General Public License version 2 as published by the Free
5
 * Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * version 2 along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
 * 02110-1301, USA.
16
 */
17

18
#include "suricata-common.h"
19
#include "util-lua-log.h"
20
#include "util-lua.h"
21
#include "util-debug.h"
22

23
#include "lauxlib.h"
24

25
static bool LuaGetAr(lua_State *L, lua_Debug *ar)
UNCOV
26
{
×
UNCOV
27
    if (lua_getstack(L, 1, ar) && lua_getinfo(L, "nSl", ar)) {
×
UNCOV
28
        return true;
×
UNCOV
29
    }
×
30
    return false;
×
UNCOV
31
}
×
32

33
static int LuaLogInfo(lua_State *L)
UNCOV
34
{
×
UNCOV
35
    const char *msg = luaL_checkstring(L, 1);
×
UNCOV
36
    lua_Debug ar;
×
UNCOV
37
    if (LuaGetAr(L, &ar)) {
×
UNCOV
38
        const char *funcname = ar.name ? ar.name : ar.what;
×
UNCOV
39
        SCLogInfoRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
UNCOV
40
    } else {
×
41
        SCLogInfo("%s", msg);
×
42
    }
×
UNCOV
43
    return 0;
×
UNCOV
44
}
×
45

46
static int LuaLogNotice(lua_State *L)
UNCOV
47
{
×
UNCOV
48
    const char *msg = luaL_checkstring(L, 1);
×
UNCOV
49
    lua_Debug ar;
×
UNCOV
50
    if (LuaGetAr(L, &ar)) {
×
UNCOV
51
        const char *funcname = ar.name ? ar.name : ar.what;
×
UNCOV
52
        SCLogNoticeRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
UNCOV
53
    } else {
×
54
        SCLogNotice("%s", msg);
×
55
    }
×
56

UNCOV
57
    return 0;
×
UNCOV
58
}
×
59

60
static int LuaLogWarning(lua_State *L)
61
{
×
62
    const char *msg = luaL_checkstring(L, 1);
×
63
    lua_Debug ar;
×
64
    if (LuaGetAr(L, &ar)) {
×
65
        const char *funcname = ar.name ? ar.name : ar.what;
×
66
        SCLogWarningRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
67
    } else {
×
68
        SCLogWarning("%s", msg);
×
69
    }
×
70
    return 0;
×
71
}
×
72

73
static int LuaLogError(lua_State *L)
74
{
×
75
    const char *msg = luaL_checkstring(L, 1);
×
76
    lua_Debug ar;
×
77
    if (LuaGetAr(L, &ar)) {
×
78
        const char *funcname = ar.name ? ar.name : ar.what;
×
79
        SCLogErrorRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
80
    } else {
×
81
        SCLogError("%s", msg);
×
82
    }
×
83
    return 0;
×
84
}
×
85

86
static int LuaLogDebug(lua_State *L)
87
{
×
88
#ifdef DEBUG
89
    const char *msg = luaL_checkstring(L, 1);
90
    lua_Debug ar;
91
    if (LuaGetAr(L, &ar)) {
92
        const char *funcname = ar.name ? ar.name : ar.what;
93
        SCLogDebugRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
94
    } else {
95
        SCLogDebug("%s", msg);
96
    }
97
#endif
98
    return 0;
×
99
}
×
100

101
static int LuaLogConfig(lua_State *L)
102
{
×
103
    const char *msg = luaL_checkstring(L, 1);
×
104
    lua_Debug ar;
×
105
    if (LuaGetAr(L, &ar)) {
×
106
        const char *funcname = ar.name ? ar.name : ar.what;
×
107
        SCLogConfigRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
108
    } else {
×
109
        SCLogConfig("%s", msg);
×
110
    }
×
111
    return 0;
×
112
}
×
113

114
static int LuaLogPerf(lua_State *L)
115
{
×
116
    const char *msg = luaL_checkstring(L, 1);
×
117
    lua_Debug ar;
×
118
    if (LuaGetAr(L, &ar)) {
×
119
        const char *funcname = ar.name ? ar.name : ar.what;
×
120
        SCLogPerfRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
121
    } else {
×
122
        SCLogPerf("%s", msg);
×
123
    }
×
124
    return 0;
×
125
}
×
126

127
static const struct luaL_Reg loglib[] = {
128
    // clang-format off
129
    { "info", LuaLogInfo },
130
    { "notice", LuaLogNotice },
131
    { "warning", LuaLogWarning },
132
    { "error", LuaLogError },
133
    { "debug", LuaLogDebug },
134
    { "config", LuaLogConfig },
135
    { "perf", LuaLogPerf },
136
    { NULL, NULL }
137
    // clang-format on
138
};
139

140
int SCLuaLoadLogLib(lua_State *L)
UNCOV
141
{
×
UNCOV
142
    luaL_newlib(L, loglib);
×
UNCOV
143
    return 1;
×
UNCOV
144
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc