Skip to content

Commit

Permalink
Merge pull request #40 from karolyi/master
Browse files Browse the repository at this point in the history
Add syntax for uwsgi logs
  • Loading branch information
folkertvanheusden authored Aug 11, 2024
2 parents f24eb8d + c4aa491 commit 990efae
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 25 deletions.
66 changes: 44 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ endif()
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
option(UTF8_SUPPORT "Build with UTF8 support" ON)
endif()

option(USE_CPPCHECK "Looking for cppcheck program ..." ON)


add_definitions(-D_FORTIFY_SOURCE=2)
add_definitions(-DCONFIG_FILE=\"/etc/multitail.conf\")
add_definitions(-DVERSION=\"${VERSION}\")
add_definitions(-D${CMAKE_C_PLATFORM_ID})
message(STATUS "CMAKE_C_PLATFORM_ID=${CMAKE_C_PLATFORM_ID}")
Expand All @@ -75,26 +75,6 @@ endif()
message(STATUS "PANEL_LIBRARY=${PANEL_LIBRARY}")


# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
# ``find_package(Curses)`` call if NCurses functionality is required.
set(CURSES_NEED_NCURSES TRUE)
find_file(CURSES_INCLUDE_FILE ncurses.h)
find_package(Curses REQUIRED)
if(CURSES_FOUND)
message(STATUS "CURSES_NCURSES_LIBRARY=${CURSES_NCURSES_LIBRARY}")
include_directories(${CURSES_INCLUDE_DIRS})
endif()

set(EXTRA_LIBS "-lutil -lm")


#
# Where to put all the RUNTIME targets when built. This variable is used to
# initialize the RUNTIME_OUTPUT_DIRECTORY property on all the targets.
#
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)


# use the lib to build bin
add_executable(multitail
clipboard.c
Expand Down Expand Up @@ -143,7 +123,47 @@ add_executable(multitail
utils.h
version.h
)
target_link_libraries(multitail ${CURSES_LIBRARIES} ${PANEL_LIBRARY} ${EXTRA_LIBS})

set(EXTRA_LIBS "-lutil -lm")

if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CURSES_INCLUDE_PATH "/usr/include")
add_definitions(-DCONFIG_FILE=\"/usr/local/etc/multitail.conf\")
if (EXISTS "/usr/local/include/gnu/regex.h")
add_library(gnuregex SHARED IMPORTED)
set_target_properties(
gnuregex PROPERTIES
IMPORTED_LOCATION "/usr/local/lib/libgnuregex.so"
INTERFACE_INCLUDE_DIRECTORIES "/usr/local/include/gnu")
else()
message(FATAL_ERROR "/usr/local/include/gnu/regex.h missing, did you install libgnuregex?")
endif()
else ()
add_definitions(-DCONFIG_FILE=\"/etc/multitail.conf\")
endif()

# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
# ``find_package(Curses)`` call if NCurses functionality is required.
set(CURSES_NEED_NCURSES TRUE)
find_file(CURSES_INCLUDE_FILE ncurses.h)
find_package(Curses REQUIRED)
if(CURSES_FOUND)
message(STATUS "CURSES_NCURSES_LIBRARY=${CURSES_NCURSES_LIBRARY}")
include_directories(${CURSES_INCLUDE_DIRS})
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
target_link_libraries(multitail gnuregex ${CURSES_LIBRARIES} ${PANEL_LIBRARY} ${EXTRA_LIBS})
else()
target_link_libraries(multitail ${CURSES_LIBRARIES} ${PANEL_LIBRARY} ${EXTRA_LIBS})
endif()

#
# Where to put all the RUNTIME targets when built. This variable is used to
# initialize the RUNTIME_OUTPUT_DIRECTORY property on all the targets.
#
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)



# install the bin
Expand Down Expand Up @@ -180,3 +200,5 @@ message("CMAKE_C_LIBRARY_ARCHITECTURE ${CMAKE_C_LIBRARY_ARCHITECTURE}")


set(CMAKE_BUILD_TYPE RelWithDebInfo)

# vim: ft=cmake:sw=4:ts=4:smarttab:expandtab
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ MANDIR=$(SHAREDIR)/man
MAN1DIR=$(MANDIR)/man1
DOCDIR=$(SHAREDIR)/doc/multitail-$(VERSION)

SYSCONFDIR=/etc
ifeq ($(PLATFORM),FreeBSD)
SYSCONFDIR=$(PREFIX)/etc
else
SYSCONFDIR=/etc
endif
CONFIG_FILE=$(SYSCONFDIR)/multitail.conf
CONFIG_DIR=$(SYSCONFDIR)/multitail

Expand Down
4 changes: 4 additions & 0 deletions mt.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#ifndef AIX
#if defined(__FreeBSD__)
#include <termios.h>
#else
#include <sys/termios.h> /* needed on Solaris 8 */
#endif
#endif
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>
Expand Down
9 changes: 7 additions & 2 deletions mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ typedef enum { SCHEME_TYPE_EDIT = 0, SCHEME_TYPE_FILTER } filter_edit_scheme_t;
#endif

#if defined(UTF8_SUPPORT) && !defined(__APPLE__)
#include <ncursesw/panel.h>
#include <ncursesw/ncurses.h>
#if defined(__FreeBSD__) || defined (__linux__)
#include <panel.h>
#include <curses.h>
#else
#include <ncursesw/panel.h>
#include <ncursesw/ncurses.h>
#endif
#else
#if defined(__APPLE__)
#include <ncurses.h>
Expand Down
37 changes: 37 additions & 0 deletions multitail.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,16 @@ cs_re_s:cyan,,bold:TunnelGroup <(\S+?)>
cs_re_s:green,,bold:IPv4 Address <([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})>
cs_re_s:green,,bold: Assigned IP=([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})

# dovecot
colorscheme:dovecot
cs_re:cyan::
cs_re:blue|blue,,bold:^... .. ..:..:..
cs_re:yellow,,bold:imap-login
cs_re:yellow,,bold:pop3-login
cs_re:green:<[^>]*>
cs_re:red:auth failed
cs_re:magenta:TLS

#
# colorscript: colorscripts are external scripts that decide what colors to use
# for input they receive the line that needs colors
Expand Down Expand Up @@ -1497,3 +1507,30 @@ scrollback_search_new_window:yes
# set to (yes) to map delete key as backspace key.
# this is useful if you are using mac
map_delete_as_backspace:no

# ----
#
# uwsgi log https://gist.github.com/karolyi/3032020b4d62c6fd0b9148db1a242548
colorscheme:uwsgi:https://uwsgi-docs.readthedocs.io/en/latest/
# HTTP method highlighting
cs_re_s:cyan:\{[0-9]+ vars in [0-9]+ bytes\} \[.*\] (GET)
cs_re_s:magenta:\{[0-9]+ vars in [0-9]+ bytes\} \[.*\] (POST|PUT|DELETE|OPTIONS)
# Response time highlighting: >500: yellow, >750ms: magenta-bold, >1000ms: red-bold
cs_re_val_bigger:red,,bold:1000:generated [0-9]+ bytes in ([0-9]+) msecs
cs_re_val_bigger:magenta,,bold:750:generated [0-9]+ bytes in ([0-9]+) msecs
cs_re_val_bigger:yellow:500:generated [0-9]+ bytes in ([0-9]+) msecs
cs_re_s:green:generated [0-9]+ bytes in ([0-9]+) msecs
# Request path highlighting with underline
cs_re_s:white,,underline:\[pid: [0-9]+\|app: [0-9]+\|req: [0-9]+\/[0-9]+\].*[A-Z]+ ([^ ]+)
# HTTP statuscode highlighting
cs_re_val_bigger:red,,bold:499:generated [0-9]+ bytes in [0-9]+ msecs \(HTTP\/[0-9]+\.[0-9]+ ([0-9]+)\)
cs_re_val_bigger:red:399:generated [0-9]+ bytes in [0-9]+ msecs \(HTTP\/[0-9]+\.[0-9]+ ([0-9]+)\)
cs_re_val_bigger:yellow:299:generated [0-9]+ bytes in [0-9]+ msecs \(HTTP\/[0-9]+\.[0-9]+ ([0-9]+)\)
cs_re_s:white,,bold:generated [0-9]+ bytes in [0-9]+ msecs \(HTTP\/[0-9]+\.[0-9]+ ([0-9]+)\)
# IP address highlighting
cs_re_s:blue,,bold:\[pid: [0-9]+\|app: [0-9]+\|req: [0-9]+\/[0-9]+\] ([0-9a-f:\.]+)
# Time highlighting
cs_re_s:white,,bold:\{[0-9]+ vars in [0-9]+ bytes\} (\[).* ([0-9]+:[0-9]+:[0-9]+) .*(\])
scheme:uwsgi:/var/log/uwsgi

# ----
4 changes: 4 additions & 0 deletions term.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
#include <stropts.h>
#endif
#ifndef AIX
#if defined(__FreeBSD__)
#include <termios.h>
#else
#include <sys/termios.h> /* needed on Solaris 8 */
#endif
#endif
#include <sys/socket.h>
#include <netinet/in.h>

Expand Down

0 comments on commit 990efae

Please sign in to comment.