Skip to content

Commit 8cd757e

Browse files
drmpegmormj
authored andcommitted
gr-blocks: Squelch debug messages in file sink.
Signed-off-by: Ron Economos <[email protected]>
1 parent b98599b commit 8cd757e

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

gr-blocks/include/gnuradio/blocks/file_sink_base.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ class BLOCKS_API file_sink_base
3232
boost::mutex d_mutex;
3333
bool d_unbuffered;
3434
bool d_append;
35-
gr::logger d_base_logger;
35+
gr::logger_ptr d_base_logger;
36+
gr::logger_ptr d_base_debug_logger;
3637

3738
protected:
3839
file_sink_base(const char* filename, bool is_binary, bool append);
3940

4041
public:
41-
file_sink_base() : d_base_logger("unitialized file_sink_base") {}
42+
file_sink_base() {}
4243
~file_sink_base();
4344

4445
/*!

gr-blocks/lib/file_sink_base.cc

+9-13
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,16 @@ namespace gr {
4343
namespace blocks {
4444

4545
file_sink_base::file_sink_base(const char* filename, bool is_binary, bool append)
46-
: d_fp(0),
47-
d_new_fp(0),
48-
d_updated(false),
49-
d_is_binary(is_binary),
50-
d_append(append),
51-
d_base_logger("file_sink_base")
46+
: d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary), d_append(append)
5247
{
48+
gr::configure_default_loggers(d_base_logger, d_base_debug_logger, "file_sink_base");
5349
if (!open(filename))
5450
throw std::runtime_error("can't open file");
5551
}
5652

5753
file_sink_base::~file_sink_base()
5854
{
59-
d_base_logger.info("[destructor] Closing file");
55+
d_base_debug_logger->debug("[destructor] Closing file");
6056
close();
6157
if (d_fp) {
6258
fclose(d_fp);
@@ -67,7 +63,7 @@ file_sink_base::~file_sink_base()
6763
bool file_sink_base::open(const char* filename)
6864
{
6965
gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function
70-
d_base_logger.info("opening file {:s}", filename);
66+
d_base_debug_logger->debug("opening file {:s}", filename);
7167

7268
// we use the open system call to get access to the O_LARGEFILE flag.
7369
int fd;
@@ -79,7 +75,7 @@ bool file_sink_base::open(const char* filename)
7975
flags = O_WRONLY | O_CREAT | O_TRUNC | OUR_O_LARGEFILE | OUR_O_BINARY;
8076
}
8177
if ((fd = ::open(filename, flags, 0664)) < 0) {
82-
d_base_logger.error("[::open] {:s}: {:s}", filename, strerror(errno));
78+
d_base_logger->error("[::open] {:s}: {:s}", filename, strerror(errno));
8379
return false;
8480
}
8581
if (d_new_fp) { // if we've already got a new one open, close it
@@ -88,7 +84,7 @@ bool file_sink_base::open(const char* filename)
8884
}
8985

9086
if ((d_new_fp = fdopen(fd, d_is_binary ? "wb" : "w")) == NULL) {
91-
d_base_logger.error("[fdopen] {:s}: {:s}", filename, strerror(errno));
87+
d_base_logger->error("[fdopen] {:s}: {:s}", filename, strerror(errno));
9288
::close(fd); // don't leak file descriptor if fdopen fails.
9389
}
9490

@@ -100,7 +96,7 @@ void file_sink_base::close()
10096
{
10197
gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function
10298

103-
d_base_logger.info("Closing file");
99+
d_base_debug_logger->debug("Closing file");
104100
if (d_new_fp) {
105101
fclose(d_new_fp);
106102
d_new_fp = 0;
@@ -112,7 +108,7 @@ void file_sink_base::do_update()
112108
{
113109
if (d_updated) {
114110
gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this block
115-
d_base_logger.info("updating");
111+
d_base_debug_logger->debug("updating");
116112
if (d_fp)
117113
fclose(d_fp);
118114
d_fp = d_new_fp; // install new file pointer
@@ -123,7 +119,7 @@ void file_sink_base::do_update()
123119

124120
void file_sink_base::set_unbuffered(bool unbuffered)
125121
{
126-
d_base_logger.info("Setting to {:s}buffered state", unbuffered ? "un" : "");
122+
d_base_debug_logger->debug("Setting to {:s}buffered state", unbuffered ? "un" : "");
127123
d_unbuffered = unbuffered;
128124
}
129125

gr-blocks/python/blocks/bindings/file_sink_base_python.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/* BINDTOOL_GEN_AUTOMATIC(0) */
1515
/* BINDTOOL_USE_PYGCCXML(0) */
1616
/* BINDTOOL_HEADER_FILE(file_sink_base.h) */
17-
/* BINDTOOL_HEADER_FILE_HASH(b832eef38e5444b08f329837184e86c8) */
17+
/* BINDTOOL_HEADER_FILE_HASH(c567888586a246a945067bdad44c874c) */
1818
/***********************************************************************************/
1919

2020
#include <pybind11/complex.h>

0 commit comments

Comments
 (0)