Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created fine-grained FA definitions #1496

Merged
merged 6 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions apps/logsupport_appdefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,40 @@
LogFANames::LogFANames()
{
Install("GENERAL", SRT_LOGFA_GENERAL);

Install("CONTROL", SRT_LOGFA_CONTROL);
Install("DATA", SRT_LOGFA_DATA);
Install("SOCKMGMT", SRT_LOGFA_SOCKMGMT);
Install("CONN", SRT_LOGFA_CONN);
Install("XTIMER", SRT_LOGFA_XTIMER);
Install("TSBPD", SRT_LOGFA_TSBPD);
Install("REXMIT", SRT_LOGFA_REXMIT);
Install("RSRC", SRT_LOGFA_RSRC);

Install("CONGEST", SRT_LOGFA_CONGEST);
Install("PFILTER", SRT_LOGFA_PFILTER);

Install("API_CTRL", SRT_LOGFA_API_CTRL);

Install("QUE_CTRL", SRT_LOGFA_QUE_CTRL);

Install("EPOLL_UPD", SRT_LOGFA_EPOLL_UPD);

Install("API_RECV", SRT_LOGFA_API_RECV);
Install("BUF_RECV", SRT_LOGFA_BUF_RECV);
Install("QUE_RECV", SRT_LOGFA_QUE_RECV);
Install("CHN_RECV", SRT_LOGFA_CHN_RECV);
Install("GRP_RECV", SRT_LOGFA_GRP_RECV);

Install("API_SEND", SRT_LOGFA_API_SEND);
Install("BUF_SEND", SRT_LOGFA_BUF_SEND);
Install("QUE_SEND", SRT_LOGFA_QUE_SEND);
Install("CHN_SEND", SRT_LOGFA_CHN_SEND);
Install("GRP_SEND", SRT_LOGFA_GRP_SEND);

Install("INTERNAL", SRT_LOGFA_INTERNAL);

Install("QUE_MGMT", SRT_LOGFA_QUE_MGMT);
Install("CHN_MGMT", SRT_LOGFA_CHN_MGMT);
Install("GRP_MGMT", SRT_LOGFA_GRP_MGMT);
Install("EPOLL_API", SRT_LOGFA_EPOLL_API);

Install("HAICRYPT", SRT_LOGFA_HAICRYPT);
Install("APPLOG", SRT_LOGFA_APPLOG);
}
2 changes: 1 addition & 1 deletion haicrypt/haicrypt_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
extern srt_logging::LogConfig srt_logger_config;

// LOGFA symbol defined in srt.h
srt_logging::Logger hclog(SRT_LOGFA_HAICRYPT, srt_logger_config, "SRT.k");
srt_logging::Logger hclog(SRT_LOGFA_HAICRYPT, srt_logger_config, "SRT.hc");

extern "C" {

Expand Down
98 changes: 77 additions & 21 deletions scripts/generate-logging-defs.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set model {
longname
shortname
id
description
}

# Logger definitions.
Expand All @@ -27,20 +28,43 @@ set model {
# Use values greater than 0. Value 0 is reserved for LOGFA_GENERAL,
# which is considered always enabled.
set loggers {
GENERAL g 0
CONTROL mg 2
DATA d 3
TSBPD ts 4
REXMIT rx 5
CONGEST cc 7
GENERAL gg 0 "General uncategorized log, for serious issues only"
SOCKMGMT sm 1 "Socket create/open/close/configure activities"
CONN cn 2 "Connection establishment and handshake"
XTIMER xt 3 "The checkTimer and around activities"
TSBPD ts 4 "The TsBPD thread"
RSRC rs 5 "System resource allocation and management"
CONGEST cc 7 "Congestion control module"
PFILTER pf 8 "Packet filter module"
API_CTRL ac 11 "API part for socket and library managmenet"
QUE_CTRL qc 13 "Queue control activities"
EPOLL_UPD ei 16 "EPoll, internal update activities"

API_RECV ar 21 "API part for receiving"
BUF_RECV br 22 "Buffer, receiving side"
QUE_RECV qr 23 "Queue, receiving side"
CHN_RECV kr 24 "CChannel, receiving side"
GRP_RECV gr 25 "Group, receiving side"

API_SEND as 31 "API part for sending"
BUF_SEND bs 32 "Buffer, sending side"
QUE_SEND qs 33 "Queue, sending side"
CHN_SEND ks 34 "CChannel, sending side"
GRP_SEND gs 35 "Group, sending side"

INTERNAL in 41 "Internal activities not connected directly to a socket"
QUE_MGMT qm 43 "Queue, management part"
CHN_MGMT km 44 "CChannel, management part"
GRP_MGMT gm 45 "Group, management part"
EPOLL_API ea 46 "EPoll, API part"
}

set hidden_loggers {
# Haicrypt logging - usually off.
HAICRYPT hc 6

# APPLOG=10 - defined in apps, this is only a stub to lock the value
# APPLOG ap 10
HAICRYPT hc 6 "Haicrypt module area"
# defined in apps, this is only a stub to lock the value
APPLOG ap 10 "Applications"
}

set globalheader {
Expand Down Expand Up @@ -91,11 +115,11 @@ proc GenerateModelForSrtH {} {
if { $state == "read" } {

if { $pass != "passed" } {
set re [regexp {^\#define SRT_LOGFA_} $line]

set re [regexp {SRT_LOGFA BEGIN GENERATED SECTION} $line]
if {$re} {
set state skip
set pass found
continue
}

}
Expand All @@ -110,15 +134,16 @@ proc GenerateModelForSrtH {} {
continue
}

if {[regexp {^\#define SRT_LOGFA_} $line]} {
set re [regexp {SRT_LOGFA END GENERATED SECTION} $line]
if {!$re} {
# Still SRT_LOGFA definitions
continue
}

# End of generated section. Switch back to pass-thru.

# First fill the gap
append contents "\$entries\n\n"
append contents "\n\$entries\n\n"

append contents "$line\n"
set state read
Expand All @@ -137,14 +162,26 @@ proc GenerateModelForSrtH {} {
}

# COMMENTS NOT ALLOWED HERE! Only as C++ comments inside C++ model code.
# Note: The syntax %<command> is a high-level command execution. This declares
# a command that must be executed to GENERATE the model. Then, [subst] is executed
# (NOTE: Tcl syntax highlighter will likely falsely highlight # as comment here)
#
# Model: TARGET-NAME { format-model logger-pattern hidden-logger-pattern }
#
# Special syntax:
#
# %<command> : a high-level command execution. This declares a command that
# must be executed to GENERATE the model. Then, [subst] is executed
# on the results.
#
# = : when placed as the hidden-logger-pattern, it's equal to logger-pattern.
#
set generation {
srtcore/srt.h {

{%GenerateModelForSrtH}
{#define [format "%-20s %d" SRT_LOGFA_${longname} $id] // ${shortname}log}
{#define [format "%-20s %d" SRT_LOGFA_${longname} $id] // ${shortname}log}

{#define [format "%-20s %-3d" SRT_LOGFA_${longname} $id] // ${shortname}log: $description}

=
}

srtcore/logger_default.cpp {
Expand Down Expand Up @@ -332,15 +369,22 @@ proc generate_file {od target} {
append entries "\n"
}

append entries ${ptabprefix}[subst -nobackslashes $pattern]\n
append entries "${ptabprefix}[subst -nobackslashes $pattern]\n"
set prevval $id
}
}

if {$hpattern != ""} {
set hpattern [string trim $hpattern]
if {$hpattern == "="} {
set hpattern $pattern
} else {
set hpattern [string trim $hpattern]
}

# Extra line to separate from the normal entries
append entries "\n"
foreach [list {*}$::model] [no_comments $::hidden_loggers] {
append entries ${ptabprefix}[subst -nobackslashes $hpattern]\n
append entries "${ptabprefix}[subst -nobackslashes $hpattern]\n"
}
}

Expand All @@ -361,6 +405,18 @@ proc generate_file {od target} {
puts $od [string trim [subst -nocommands -nobackslashes $format_model]]
}

proc debug_vars {list} {
set output ""
foreach name $list {
upvar $name _${name}
lappend output "${name}=[set _${name}]"
}

return $output
}

# MAIN

set entryfiles $argv

if {$entryfiles == ""} {
Expand Down
Loading