Skip to content

Commit 81a15a0

Browse files
committed
refactor(core/prodtest): move syslog prodtest command to prodtest project
[no changelog]
1 parent fa6f82e commit 81a15a0

5 files changed

Lines changed: 64 additions & 32 deletions

File tree

core/SConscript.prodtest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ SOURCE_PRODTEST = [
211211
'embed/projects/prodtest/cmd/prodtest_tamper.c',
212212
'embed/projects/prodtest/cmd/prodtest_sbu.c',
213213
'embed/projects/prodtest/cmd/prodtest_secure_channel.c',
214+
'embed/projects/prodtest/cmd/prodtest_syslog.c',
214215
'embed/projects/prodtest/cmd/prodtest_telemetry.c',
215216
'embed/projects/prodtest/cmd/prodtest_touch.c',
216217
'embed/projects/prodtest/cmd/prodtest_tropic.c',

core/SConscript.prodtest_emu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ SOURCE_PRODTEST = [
184184
'embed/projects/prodtest/cmd/prodtest_tamper.c',
185185
'embed/projects/prodtest/cmd/prodtest_sbu.c',
186186
'embed/projects/prodtest/cmd/prodtest_secure_channel.c',
187+
'embed/projects/prodtest/cmd/prodtest_syslog.c',
187188
'embed/projects/prodtest/cmd/prodtest_telemetry.c',
188189
'embed/projects/prodtest/cmd/prodtest_touch.c',
189190
'embed/projects/prodtest/cmd/prodtest_tropic.c',

core/embed/projects/prodtest/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn main() -> Result<()> {
4444
"prodtest_tamper.c",
4545
"prodtest_sbu.c",
4646
"prodtest_secure_channel.c",
47+
"prodtest_syslog.c",
4748
"prodtest_telemetry.c",
4849
"prodtest_touch.c",
4950
"prodtest_tropic.c",
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* This file is part of the Trezor project, https://trezor.io/
3+
*
4+
* Copyright (c) SatoshiLabs
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifdef USE_DBG_CONSOLE
21+
22+
#include <trezor_rtl.h>
23+
24+
#include <rtl/cli.h>
25+
#include <sys/logging.h>
26+
#include <sys/syslog.h>
27+
28+
#include "prodtest_error_codes.h"
29+
30+
static void prodtest_set_log_filter(cli_t* cli) {
31+
const char* filter = cli_arg(cli, "filter");
32+
size_t filter_len = strlen(filter);
33+
34+
if (filter_len == 0) {
35+
cli_error_arg(cli, "Expecting filter string.");
36+
return;
37+
}
38+
39+
if (cli_arg_count(cli) > 1) {
40+
cli_error_arg_count(cli);
41+
return;
42+
}
43+
44+
if (!syslog_set_filter(filter, filter_len)) {
45+
cli_error(cli, PRODTEST_ERR_SYSLOG_FILTER_SET, "Failed to set log filter.");
46+
return;
47+
}
48+
49+
cli_ok(cli, "");
50+
}
51+
52+
// clang-format off
53+
54+
PRODTEST_CLI_CMD(
55+
.name = "log-filter",
56+
.func = prodtest_set_log_filter,
57+
.info = "Set logging filter",
58+
.args = "<filter>"
59+
);
60+
61+
#endif // USE_DBG_CONSOLE

core/embed/sys/dbg/syslog.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -266,35 +266,3 @@ void syslog_tsh_error(ts_t status, const char* file, int line) {
266266
syslog_printf(&source, LOG_LEVEL_ERR, "%s at %s:%d", ts_string(status), file,
267267
line);
268268
}
269-
270-
#ifdef TREZOR_PRODTEST
271-
272-
#include <rtl/cli.h>
273-
274-
#include "prodtest_error_codes.h"
275-
276-
static void prodtest_set_log_filter(cli_t* cli) {
277-
const char* filter = cli_arg(cli, "filter");
278-
size_t filter_len = strlen(filter);
279-
280-
if (filter_len == 0) {
281-
cli_error_arg(cli, "Expecting filter string.");
282-
return;
283-
}
284-
285-
if (cli_arg_count(cli) > 1) {
286-
cli_error_arg_count(cli);
287-
return;
288-
}
289-
290-
if (!syslog_set_filter(filter, filter_len)) {
291-
cli_error(cli, PRODTEST_ERR_SYSLOG_FILTER_SET, "Failed to set log filter.");
292-
}
293-
294-
cli_ok(cli, "");
295-
}
296-
297-
PRODTEST_CLI_CMD(.name = "log-filter", .func = prodtest_set_log_filter,
298-
.info = "Set logging filter", .args = "<filter>");
299-
300-
#endif // TREZOR_PRODTEST

0 commit comments

Comments
 (0)