-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdLog.cpp
93 lines (69 loc) · 1.95 KB
/
cmdLog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
Module: cmdLog.cpp
Function:
Process the "log" command
Copyright and License:
This file copyright (C) 2021 by
MCCI Corporation
3520 Krums Corners Road
Ithaca, NY 14850
See accompanying LICENSE file for copyright and license information.
Author:
Terry Moore, MCCI Corporation May 2021
*/
#include "Catena4610_cmd.h"
#include <Catena_Log.h>
using namespace McciCatena;
/*
Name: ::cmdLog()
Function:
Command dispatcher for "log" command.
Definition:
McciCatena::cCommandStream::CommandFn cmdLog;
McciCatena::cCommandStream::CommandStatus cmdLog(
cCommandStream *pThis,
void *pContext,
int argc,
char **argv
);
Description:
The "log" command has the following syntax:
log
Display the current log mask.
log {number}
Set the log mask to {number}
Returns:
cCommandStream::CommandStatus::kSuccess if successful.
Some other value for failure.
*/
// argv[0] is "log"
// argv[1] is new log flag mask; if omitted, mask is printed
cCommandStream::CommandStatus cmdLog(
cCommandStream *pThis,
void *pContext,
int argc,
char **argv
)
{
if (argc > 2)
return cCommandStream::CommandStatus::kInvalidParameter;
if (argc == 1)
{
pThis->printf("log flags: %#x\n", gLog.getFlags());
return cCommandStream::CommandStatus::kSuccess;
}
else
{
cCommandStream::CommandStatus status;
uint32_t newFlags;
// get arg 1 as newFlags; default is irrelevant
status = cCommandStream::getuint32(argc, argv, 1, /*radix*/ 0, newFlags, /* default */ 0);
if (status == cCommandStream::CommandStatus::kSuccess)
{
cLog::DebugFlags const oldFlags =
gLog.setFlags(cLog::DebugFlags(newFlags));
pThis->printf("log flags: %#x -> %#x\n", oldFlags, newFlags);
}
return status;
}
}