Master Thesis Code
by Simon Moser
Loading...
Searching...
No Matches
log_entry.m
Go to the documentation of this file.
1% =========================================================================== %
2%> @brief log entry to a log file
3%>
4%> this function logs an entry to a log file.
5%>
6%> @param msg message to log
7%> @param ptp_num participant number (default: 0)
8%> @param level log level (default: 4)
9%>
10%> @retval none
11%>
12%> @note log levels:
13%> - 1: FATAL
14%> - 2: ERROR
15%> - 3: WARNING
16%> - 4: INFO
17%> - 5: DEBUG
18%>
19%> @copyright see the file @ref LICENSE in the root directory of the repository
20% =========================================================================== %
21
22function log_entry(msg, ptp_num, level, trial)
23
24arguments
25 msg (1,:) char
26 ptp_num (1,1) double = 0
27 level (1,1) double = 4
28 trial (1,1) string = ""
29end
30
31switch level
32 case 1
33 lvl_str = "FATAL ";
34 case 2
35 lvl_str = "ERROR ";
36 case 3
37 lvl_str = "WARNING";
38 case 4
39 lvl_str = "INFO ";
40 case 5
41 lvl_str = "DEBUG ";
42 otherwise
43 lvl_str = "UNKNOWN";
44end
45
46if strlength(trial)
47 msg = msg + " (Trial: " + trial + ")";
48end
49
50diary on
51fprintf("%s; %s; %2d; %s\n", datetime('now', 'Format', 'yyyy-MM-dd HH:mm:ss'), lvl_str, ptp_num, msg)
52diary off
53
54end
function log_entry(in msg, in ptp_num, in level, in trial)
log entry to a log file