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

Pull Logging and Logic Improvements #127

Merged
merged 46 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8753e7e
added entry/finished logs for all onion handler callbacks
BLuedtke Feb 21, 2023
747627d
further fixes
BLuedtke Feb 28, 2023
1b48b76
Improve log schema consistency
BLuedtke Mar 1, 2023
2c7b38c
Improvements and Merge from branch master
BLuedtke Nov 11, 2023
d5ee500
Whitespace and formatting
BLuedtke Nov 11, 2023
542c2d8
Request Logging Descript in Readme and verif new log
BLuedtke Nov 11, 2023
93fefaa
improve logging, validation, logic in admin, controller
BLuedtke Nov 11, 2023
afe862d
improve logging, logic, in driver and monitor
BLuedtke Nov 11, 2023
9f72567
improve logging in upload
BLuedtke Nov 11, 2023
88b85b6
outfactor common grab-id and train-id check
BLuedtke Nov 11, 2023
a8799cb
Improve includes (order, duplicates)
BLuedtke Nov 12, 2023
39c1783
improved logging when stopping server
BLuedtke Nov 14, 2023
4d6f1e2
improved startup logging
BLuedtke Nov 14, 2023
ad30790
admin handler minor log improv
BLuedtke Nov 14, 2023
2c76bf3
consistent log before or after mutex in driveroute
BLuedtke Nov 14, 2023
94a0037
admin import removed dupl and unused
BLuedtke Nov 14, 2023
0005f7d
Applied (multi-arg) formatting scheme
BLuedtke Nov 14, 2023
2eb3304
removed unnecessary log in upload dupl check
BLuedtke Nov 14, 2023
8e2d947
merged some lines that stay < 100
BLuedtke Nov 14, 2023
d87853e
moved train time step constant to header to resolve multi-definition
BLuedtke Nov 14, 2023
e91ebe4
Add missing va_end
BLuedtke Nov 14, 2023
ed042ad
Updated Readme
BLuedtke Nov 14, 2023
e8da5f6
improve name and log consistency for admin handler
BLuedtke Nov 15, 2023
dc42190
further name and log consistency improvements
BLuedtke Nov 15, 2023
c911869
Fix issues mentioned in PR
BLuedtke Nov 16, 2023
4dc17b9
rephrase misleading log in dyn containers interface
BLuedtke Nov 16, 2023
81e3e5b
remove unnecessary route pointer lookup
BLuedtke Nov 22, 2023
ddc4882
readme adjustments after review
BLuedtke Nov 25, 2023
72629b3
part of review comments addressed
BLuedtke Nov 25, 2023
c425513
readme review comments addressed
BLuedtke Nov 25, 2023
2ad2095
review comment addressing up to driver release train
BLuedtke Nov 25, 2023
8f585b5
handler driver fixes & improvements
BLuedtke Nov 27, 2023
09cd8c3
add "start" to req handler log pattern
BLuedtke Nov 28, 2023
9d54f71
move "getter" handlers to log only "done"
BLuedtke Nov 28, 2023
ebb0e4d
add apt update to pipeline steps
BLuedtke Nov 28, 2023
9928d8b
readme log pattern refined
BLuedtke Nov 28, 2023
029beee
refactored verification option string parser
BLuedtke Nov 28, 2023
8a1088a
engine uploader basic log refactor
BLuedtke Nov 28, 2023
463636c
engine uploader context for WS related logs
BLuedtke Nov 28, 2023
042ec48
engine uploader formatting
BLuedtke Nov 28, 2023
b1c70ce
admin verification URL formatting
BLuedtke Nov 28, 2023
fe82c6c
updated handler log format with abort and finish
BLuedtke Nov 30, 2023
021c458
address "granting in progress" discussion
BLuedtke Nov 30, 2023
c6db384
remove hardcoding route conflicts array length
BLuedtke Nov 30, 2023
c616f7f
Update Readme
BLuedtke Jan 17, 2024
3975382
log consistency in engine uploader
BLuedtke Jan 17, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ jobs:
- uses: actions/checkout@v3

- name: Install cmocka
run: sudo apt-get install -y --no-install-recommends libyaml-dev libcmocka-dev
run: sudo apt update; sudo apt-get install -y --no-install-recommends libyaml-dev libcmocka-dev

- name: Build libbidib
run: git clone --depth 1 https://github.com/uniba-swt/libbidib.git; cd libbidib; mkdir bin; cd bin; cmake ..; make -j; sudo make -j install

- name: Install pam, gnutls
run: sudo apt-get install -y --no-install-recommends libpam0g-dev libgnutls28-dev
run: sudo apt update; sudo apt-get install -y --no-install-recommends libpam0g-dev libgnutls28-dev

- name: Build libonion
run: git clone --depth 1 https://github.com/uniba-swt/onion.git; cd onion; mkdir bin; cd bin; cmake -DONION_EXAMPLES=false -DONION_USE_TESTS=false ..; make -j onion; make -j onion_static; sudo make -j install

- name: Install flex-dev, graphviz
run: sudo apt-get install -y libfl-dev graphviz
run: sudo apt update; sudo apt-get install -y libfl-dev graphviz

- name: Install forecc
run: git clone --depth 1 https://github.com/PRETgroup/ForeC.git; cd ForeC/ForeC\ Compiler; make -j; echo "FOREC_COMPILER_PATH=`pwd`" >> $GITHUB_ENV
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,29 @@ When is a grab-id reset?
is not the same as the one at the server
* If the user issues `swtbahn admin shutdown` and the system was running
* If the user issues `swtbahn config`

## Logging Format Notes
We try to use a consistent logging format in all request handlers. General workflow of how request handlers generate log messages:
1. Parse form data.
2. Validate form data. If validation fails, make a log on `ERROR` level and stop processing.
3. Make a log on log level `NOTICE` that represents the start of processing, with ` - start` at the end of the log.
4. Process request. If processing causes an error, make a log on the `ERROR` or `WARNING` log level with ` - abort` at the end of the log and stop processing.
5. Processing concluded. Indicate this by printing the log message of Step 3 again, on the same log level, with ` - finish` instead of ` - start` at the end.

For request handlers that barely do any "processing" at all; e.g. where only a status variable is updated, they only generate one log message that ends with ` - done`.
Request handlers that only return information (getters) also use the ` - done` pattern instead of `start` and `finish`, and use the log level `INFO` for the ` - done` log.

As an example, when a request is made to set point10 to the normal state, the request handler (`handler_set_point`) generates the following log messages when the processing is successful:
> LOG_NOTICE: `Request: Set point - point: point10 state: normal - start`
> _Intervening log messages from internal processing_
> LOG_NOTICE: `Request: Set point - point: point10 state: normal - finish`

If the above request was instead made with an unsupported state, e.g., `foobar`, then the request handler would generate the following log messages to say that the processing was stopped because of invalid parameters:

> LOG_NOTICE: `Request: Set point - point: point10 state: foobar - start`
> _Intervening log messages from internal processing_
> LOG_ERR: `Request: Set point - point: point10 state: foobar - invalid parameters - abort`

If the above request forgot to specify the state, i.e., the state parameter is `null`, then the request handler would only generate the following log message to say that the parameter validation failed:

> LOG_ERR: `Request: Set point - invalid parameters`
7 changes: 5 additions & 2 deletions server/src/bahn_data_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,16 @@ bool config_set_scalar_string_value(const char *type, const char *id, const char
t_interlocking_route *route = (t_interlocking_route *) obj;
route->train = strdup(value);
if (value != NULL && route->train == NULL) {
syslog_server(LOG_ERR, "config set scalar string value: unable to allocate memory for route->train");
syslog_server(LOG_ERR,
"config set scalar string value: unable to allocate memory for route->train");
}
result = true;
}
}

syslog_server(LOG_DEBUG, "Set scalar string: %s %s.%s = %s => %s", type, id, prop_name, value, result ? "true" : "false");
syslog_server(LOG_DEBUG,
"Set scalar string: %s %s.%s = %s => %s",
type, id, prop_name, value, result ? "true" : "false");
return result;
}

Expand Down
6 changes: 4 additions & 2 deletions server/src/dyn_containers_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ static void *dyn_containers_actuate(void *_) {
? engine_instance->output_nominal_speed
: -engine_instance->output_nominal_speed,
grabbed_trains[i].track_output)) {
syslog_server(LOG_ERR, "Request: Set train speed - train: %s: bad parameter values",
syslog_server(LOG_ERR,
"Dyn containers actuate - train: %s - invalid parameters",
grabbed_trains[i].name->str);
} else {
bidib_flush();
syslog_server(LOG_NOTICE, "Request: Set train speed - train: %s speed: %d",
syslog_server(LOG_NOTICE,
"Dyn containers actuate - train: %s speed: %d - set train speed",
grabbed_trains[i].name->str,
engine_instance->output_nominal_forwards
? engine_instance->output_nominal_speed
Expand Down
Loading