@@ -153,7 +153,9 @@ int Lua::run(Transaction *t) {
153153 break ;
154154 }
155155 e.append (lua_tostring (L, -1 ));
156+ #ifndef NO_LOGS
156157 t->debug (2 , e);
158+ #endif
157159 ret = false ;
158160 goto err;
159161 }
@@ -167,7 +169,9 @@ int Lua::run(Transaction *t) {
167169 e.append (" - " );
168170 e.append (luaerr);
169171 }
172+ #ifndef NO_LOGS
170173 t->debug (2 , e);
174+ #endif
171175 ret = false ;
172176 goto err;
173177 }
@@ -183,7 +187,9 @@ int Lua::run(Transaction *t) {
183187 e.append (" - " );
184188 e.append (luaerr);
185189 }
190+ #ifndef NO_LOGS
186191 t->debug (2 , e);
192+ #endif
187193 ret = false ;
188194 goto err;
189195 }
@@ -192,8 +198,9 @@ int Lua::run(Transaction *t) {
192198 if (a != NULL ) {
193199 luaRet.assign (a);
194200 }
195-
201+ # ifndef NO_LOGS
196202 t->debug (9 , " Returning from lua script: " + luaRet);
203+ #endif
197204
198205 if (luaRet.size () == 0 ) {
199206 ret = false ;
@@ -206,7 +213,9 @@ int Lua::run(Transaction *t) {
206213
207214 return ret;
208215#else
216+ #ifndef NO_LOGS
209217 t->debug (9 , " Lua support was not enabled." );
218+ #endif
210219 return false ;
211220#endif
212221}
@@ -228,7 +237,9 @@ int Lua::log(lua_State *L) {
228237
229238 /* Log message. */
230239 if (t != NULL ) {
240+ #ifndef NO_LOGS
231241 t->debug (level, text);
242+ #endif
232243 }
233244
234245 return 0 ;
@@ -320,7 +331,9 @@ int Lua::setvar(lua_State *L) {
320331
321332
322333 if (nargs != 2 ) {
334+ #ifndef NO_LOGS
323335 t->debug (8 , " m.setvar: Failed m.setvar funtion must has 2 arguments" );
336+ #endif
324337 return -1 ;
325338 }
326339 var_value = luaL_checkstring (L, 2 );
@@ -341,8 +354,10 @@ int Lua::setvar(lua_State *L) {
341354 std::string::npos);
342355
343356 } else {
357+ #ifndef NO_LOGS
344358 t->debug (8 , " m.setvar: Must specify a collection using dot character" \
345359 " - ie m.setvar(tx.myvar,mydata)" );
360+ #endif
346361 return -1 ;
347362 }
348363
@@ -380,8 +395,10 @@ std::string Lua::applyTransformations(lua_State *L, Transaction *t,
380395 if (tfn) {
381396 newVar = tfn->evaluate (newVar, t);
382397 } else {
398+ #ifndef NO_LOGS
383399 t->debug (1 , " SecRuleScript: Invalid transformation function: " \
384400 + std::string (name));
401+ #endif
385402 }
386403 delete tfn;
387404 }
@@ -402,17 +419,19 @@ std::string Lua::applyTransformations(lua_State *L, Transaction *t,
402419 newVar = tfn->evaluate (newVar, t);
403420 delete tfn;
404421 } else {
422+ #ifndef NO_LOGS
405423 t->debug (1 , " SecRuleScript: Invalid transformation function: " \
406424 + std::string (name));
425+ #endif
407426 }
408427 return newVar;
409428 }
410-
429+ # ifndef NO_LOGS
411430 t->debug (8 , " SecRuleScript: Transformation parameter must be a " \
412431 " transformation name or array of transformation names, but found " \
413432 " " + std::string (lua_typename (L, idx)) + " (type " \
414433 + std::to_string (lua_type (L, idx)) + " )" );
415-
434+ # endif
416435 return newVar;
417436}
418437#endif
0 commit comments