Skip to content

Commit caf8936

Browse files
kanard38knard38
authored andcommitted
DAOS-18292 ddb: Debug level of the DDB GO code can not be defined
Properly configure C DAOS debug facilities from Golang DDB code. Features: recovery Signed-off-by: Cedric Koch-Hofer <[email protected]>
1 parent 9891709 commit caf8936

File tree

11 files changed

+65
-22
lines changed

11 files changed

+65
-22
lines changed

src/control/cmd/ddb/main.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,36 @@ Example Paths:
179179
return nil
180180
}
181181

182+
if os.Getenv("DD_MASK") == "" {
183+
os.Setenv("DD_MASK", "mgmt,epc,csum,md,df,io,trace")
184+
}
182185
if opts.Debug {
183-
log.WithLogLevel(logging.LogLevelDebug)
184-
log.Debug("debug output enabled")
186+
log.WithLogLevel(logging.LogLevelTrace)
187+
if os.Getenv("D_LOG_MASK") == "" {
188+
os.Setenv("D_LOG_MASK", "INFO,DDB=DEBUG")
189+
}
190+
// Show debug output and above on stderr to not pollute stdout
191+
// NOTE: DD_STDERR can only be used with INFO and above.
192+
if os.Getenv("DD_STDERR") == "" {
193+
os.Setenv("DD_STDERR", "EMIT")
194+
}
195+
if os.Getenv("D_LOG_FILE") == "" {
196+
os.Setenv("D_LOG_FILE", "/dev/stderr")
197+
}
198+
} else {
199+
log.WithLogLevel(logging.LogLevelError)
200+
if os.Getenv("D_LOG_MASK") == "" {
201+
os.Setenv("D_LOG_MASK", "ERR,DDB=WARN")
202+
}
203+
// Only show warnings and above on stderr to not pollute stdout
204+
if os.Getenv("DD_STDERR") == "" {
205+
os.Setenv("DD_STDERR", "WARN")
206+
}
207+
if os.Getenv("D_LOG_FILE") == "" {
208+
os.Setenv("D_LOG_FILE", "/dev/null")
209+
}
185210
}
211+
log.Debug("debug output enabled")
186212

187213
ctx, cleanup, err := InitDdb(log)
188214
if err != nil {

src/include/daos/debug.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
ACTION(il, il, arg) \
5656
ACTION(csum, csum, arg) \
5757
ACTION(pipeline, pipeline, arg) \
58-
ACTION(stack, stack, arg)
58+
ACTION(stack, stack, arg) \
59+
ACTION(ddb, ddb, arg)
5960

6061
#define DAOS_FOREACH_DB(ACTION, arg) \
6162
/** metadata operation */ \

src/utils/ddb/ddb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
*
66
* SPDX-License-Identifier: BSD-2-Clause-Patent
77
*/
8+
#define D_LOGFAC DD_FAC(ddb)
9+
810
#include <stdlib.h>
911
#include <string.h>
1012
#include <limits.h>
13+
1114
#include <daos_errno.h>
1215
#include <daos_srv/vos.h>
1316

src/utils/ddb/ddb_commands.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
*
66
* SPDX-License-Identifier: BSD-2-Clause-Patent
77
*/
8+
#define D_LOGFAC DD_FAC(ddb)
89

9-
#include <daos/common.h>
10-
#include <daos_srv/vos.h>
1110
#include <sys/types.h>
1211
#include <time.h>
1312

14-
#include "daos_errno.h"
15-
#include "daos_srv/vos_types.h"
16-
#include "daos_types.h"
13+
#include <daos.h>
14+
#include <daos_errno.h>
15+
#include <daos_types.h>
16+
#include <daos/common.h>
17+
#include <daos_srv/vos.h>
18+
#include <daos_srv/vos_types.h>
19+
1720
#include "ddb_common.h"
1821
#include "ddb_parse.h"
1922
#include "ddb.h"
2023
#include "ddb_vos.h"
2124
#include "ddb_printer.h"
22-
#include "daos.h"
2325
#include "ddb_tree_path.h"
24-
#include "gurt/common.h"
25-
#include "gurt/debug.h"
2626

2727
#define ilog_path_required_error_message "Path to object, dkey, or akey required\n"
2828
#define error_msg_write_mode_only "Can only modify the VOS tree in 'write mode'\n"

src/utils/ddb/ddb_main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
*
66
* SPDX-License-Identifier: BSD-2-Clause-Patent
77
*/
8+
#define D_LOGFAC DD_FAC(ddb)
9+
10+
#include <stdarg.h>
11+
#include <sys/stat.h>
812

913
#include <daos/common.h>
1014
#include <daos/object.h>
15+
16+
#include "ddb.h"
1117
#include "ddb_common.h"
1218
#include "ddb_parse.h"
1319
#include "ddb_vos.h"
14-
#include "ddb.h"
15-
#include <stdarg.h>
16-
#include <sys/stat.h>
1720

1821
int
1922
ddb_init()

src/utils/ddb/ddb_mgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

89
#include <ftw.h>
910
#include <unistd.h>
@@ -13,7 +14,6 @@
1314
#include <sys/sysinfo.h>
1415
#include <linux/magic.h>
1516

16-
#include <gurt/debug.h>
1717
#include <daos_srv/control.h>
1818
#include <daos_srv/smd.h>
1919
#include <daos_srv/mgmt_tgt_common.h>

src/utils/ddb/ddb_parse.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

89
#include <wordexp.h>
910
#include <getopt.h>
10-
#include <gurt/common.h>
11-
#include "daos_errno.h"
11+
12+
#include <daos_errno.h>
13+
1214
#include "ddb_common.h"
1315
#include "ddb_parse.h"
1416

src/utils/ddb/ddb_printer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

89
#include "ddb_printer.h"
910

src/utils/ddb/ddb_spdk.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

8-
#include <bio_internal.h>
9-
#include <bio_wal.h>
9+
#include <uuid/uuid.h>
1010
#include <spdk/stdinc.h>
1111
#include <spdk/bdev.h>
1212
#include <spdk/env.h>
1313
#include <spdk/event.h>
1414
#include <spdk/blob_bdev.h>
1515
#include <spdk/blob.h>
1616
#include <spdk/string.h>
17-
#include <uuid/uuid.h>
17+
18+
#include <bio_internal.h>
19+
#include <bio_wal.h>
1820

1921
#include "ddb_common.h"
2022
#include "ddb_spdk.h"

src/utils/ddb/ddb_tree_path.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/**
22
* (C) Copyright 2023-2024 Intel Corporation.
3+
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
34
*
45
* SPDX-License-Identifier: BSD-2-Clause-Patent
56
*/
7+
#define D_LOGFAC DD_FAC(ddb)
68

79
#include "ddb_tree_path.h"
810
#include "ddb_printer.h"

0 commit comments

Comments
 (0)