Commit Graph

111 Commits (8ca9c0e8f04598ebcbe72bafce1512b8fe2f554a)

Author SHA1 Message Date
Victor Julien 481a1923b4 logging: turn SCLog and SCLogErr into funcs
Reduces compiled code size.
5 years ago
Philippe Antoine 12a3a24906 log: can use a file set from env variable
Enables the redirection of log to a file set by an environment
variable SC_LOG_FILE when SC_LOG_OP_IFACE=file
6 years ago
Danny Browning b573c16dd5 build: cbindgen
Rust headers are now generated using cbindgen. If cbindgen is present, they can
be generated during dist, otherwise they will be available for builds.
6 years ago
Victor Julien 842037d327 jansson: remove explicit <jansson.h> includes
Header is included from suricata-common.h
6 years ago
Victor Julien edd2cd626f jansson: remove HAVE_LIBJANSSON guards 6 years ago
Victor Julien 5e9714e384 rust: remove all HAVE_RUST guards 6 years ago
Jason Ish 71c53484ee logging: used fixed levels of verbosity for -v, -vv...
Change the meaning of the verbosity flag to change the log
level to fixed levels instead of being relative to whats
configured.

-v    => INFO
-vv   => PERF
-vvv  => CONIFG
-vvvv => DEBUG

But do now allow -v to decrease the verbosity.

Bug #1851
6 years ago
Jason Ish 89634b6508 logging: respect individual log levels
The log level of individual loggers (console, file, syslog) was
being capped by the default log level. For example, if the
default log level was notice, setting the file level to info
would still result in notice level logging.

Bug #3210
6 years ago
Victor Julien 2da90a1cd8 posix: remove deprecated index/rindex calls
Replace index by strchr and rindex by strrchr.

index(3) states "POSIX.1-2008 removes the specifications of index() and
rindex(), recommending strchr(3) and strrchr(3) instead."

Add index/rindex to banned function check so they don't get reintroduced.

Bug #1443.
6 years ago
Victor Julien d00950be81 log/file: use default-log-dir for suricata.log
Default to just suricata.log instead of the full path, so that
in user mode we can log in the user mode location.
6 years ago
Victor Julien d522746c01 windows: fix sc_log_stream_lock handling 7 years ago
Eric Urban 90a0731564 debug/log: add log level for JSON type
resolves #2671
7 years ago
Victor Julien 1bf658f9ee debug/log: suppress coverity checked_return warning 7 years ago
Victor Julien 023a2fe9ab unittests: fix format-truncation warning 7 years ago
Alexander Gozman 10a360280f Print syslog format with SCLogDebug() instead of printf() 7 years ago
Alexander Gozman 5c1a2b53f9 Bug #2466: map SC_LOG_CONFIG level to syslogs LOG_DEBUG 7 years ago
Victor Julien 269cd03a43 console: no color for native windows build 8 years ago
Victor Julien 99bf99c529 output: don't deadlock on log reopen failure
If output log reopen fails, don't try to output the error. This would
lead to a deadlock as reopen was called from a SCLogMessage call. This
call already held the output lock.

Bug #2306.
8 years ago
Victor Julien 81408df0cf output: clean up log API unittests
Disable for MinGW as the setenv/getenv implementations seems to
be undeterministic.
8 years ago
Alexander Gozman 63e1371c8b syslog: treat SC_LOG_PERF messages as LOG_DEBUG
SCLogMapLogLevelToSyslogLevel(): treat SC_LOG_PERF messages as LOG_DEBUG

Previously, when logging to syslog, perf events had a default EMERG priority,
which could be a bit confusing.
8 years ago
Victor Julien 62b8431fdd debug: free pcre memory used for output filtering 8 years ago
Victor Julien 67b97c7948 log: destroy file mutex 8 years ago
Jason Ish fa742d1d14 log: wrap rotation and write in lock
The application log is subject to rotation, so the check for
rotation, the actual rotation and write needs to be done under
lock to ensure the file pointer is in a consisten state
at the time of write().

Fixes issue:
https://redmine.openinfosecfoundation.org/issues/2155
8 years ago
Jason Ish 73388042b2 rust: DNS app-layer.
A DNS application layer in Rust. This is different than the
C based one, as it is partially stateless by not matching
up responses to replies.
8 years ago
Jason Ish 94032d3ada rust: wrapper around C logging, and "context"
Where the context is a struct passed from C with pointers
to all the functions that may be called.

Instead of referencing C functions directly, wrap them
in function pointers so pure Rust unit tests can still run.
8 years ago
Jason Ish de5bb1f953 rust: stub out logging from rust 8 years ago
Victor Julien ab1200fbd7 compiler: more strict compiler warnings
Set flags by default:

    -Wmissing-prototypes
    -Wmissing-declarations
    -Wstrict-prototypes
    -Wwrite-strings
    -Wcast-align
    -Wbad-function-cast
    -Wformat-security
    -Wno-format-nonliteral
    -Wmissing-format-attribute
    -funsigned-char

Fix minor compiler warnings for these new flags on gcc and clang.
8 years ago
Victor Julien 61b72c6981 output: clean up output function
Don't allocate memory per call.
9 years ago
Jason Ish fffdc6e3fd logging: hook the application log file into rotation 9 years ago
Jason Ish 73a1d04779 logging: open application log file in append mode
It was being open in read/write mode, which was likely
a mistake with append mode being the intention.
9 years ago
Victor Julien b3bf7a5729 output: introduce config and perf output levels
Goal is to reduce info output
9 years ago
Victor Julien cc2ed783c5 output: improve notice and warning/error color handling 9 years ago
Victor Julien 093ecf4798 logging: clean up at shutdown 9 years ago
Jason Ish 796dd5223b tests: no longer necessary to provide successful return code
1 pass, 0 is fail.
9 years ago
Victor Julien 3f3ed71fe7 jansson: cleanup JSON_ESCAPE_SLASH use 10 years ago
Andreas Herz 8bd9f3d072 json: fix missing includes in disable unix socket case 10 years ago
Eric Leblond 6572725a7a util-debug: don't colorize if a redirect is used
It is better to disable the color mode when a redirect of stderr
is done to avoid getting colorized output in the generated file.
10 years ago
Victor Julien 45fc619f79 logging: json output
Make JSON output optional.

Cleanups.
10 years ago
Victor Julien 126ecb3ebf logging: fix per output log formats 10 years ago
Victor Julien b51c4e608f logging: optional colors output
Construct message per output method.
10 years ago
Victor Julien b13de5bf08 logging: change newline handling 10 years ago
Victor Julien 1927b3000c output: cleanup 10 years ago
Victor Julien b30bdc21b5 logging: cleanup output API
Make SCLogMessage master of the logging. Reduces complexity
of the SCLog macro's.
10 years ago
Victor Julien d6fc6e874f log: reorganize SCLogOPIfaceCtx to make it more efficient 10 years ago
Victor Julien b9aaf5a9ab Fix potential deadlock in output
Coverity:
** CID 1296115:  Program hangs  (ORDER_REVERSAL)
/src/tm-threads.c: 1670 in TmThreadClearThreadsFamily()

The problem is with the by default unused '%m' output parameter.
To get the thread vars it takes the tv_root_lock. This may already
be locked by the calling thread. Also, it could lead to a case of
wrong lock order between the tv_root_lock and the thread_store_lock.

Very unlikely to happen though.

As the %m param isn't really used (by default) this patch just
disables it.
10 years ago
Victor Julien 9ef9a14315 Fix util-debug scan-build warnings
util-debug.c:461:12: warning: Potential leak of memory pointed to by 'substr'
    return SC_ERR_SPRINTF;
           ^~~~~~~~~~~~~~
util-debug.c:856:31: warning: Potential leak of memory pointed to by 's'
                op_ifaces_ctx = SCLogInitFileOPIface(s, NULL, SC_LOG_LEVEL_MAX);
                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util-debug.c:1349:9: warning: Potential leak of memory pointed to by 's'
    if (log_level >= 0 && log_level < SC_LOG_LEVEL_MAX)
        ^~~~~~~~~
3 warnings generated.
12 years ago
Eric Leblond 7561da4b87 debug: default logging level is notice
Update the string in message because default logging level is
now notice and not info.
12 years ago
Eric Leblond 28c5c68192 error checking: add missing alloc error treatment
The return of some malloc like functions was not treated in some
places of the code.
12 years ago
Victor Julien 35298a0146 Use %u for unsigned int in (console) output 12 years ago
Eric Leblond 2be194d03f suricata: add -v[v] option to increase verbosity
This patch adds a -v option to suricata. It increases the log level
defined in the YAML.
12 years ago