summaryrefslogtreecommitdiff
path: root/gr-blocks/lib/file_sink_base.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-blocks/lib/file_sink_base.cc')
-rw-r--r--gr-blocks/lib/file_sink_base.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/gr-blocks/lib/file_sink_base.cc b/gr-blocks/lib/file_sink_base.cc
index 75891c15b9..22dfe0dd5e 100644
--- a/gr-blocks/lib/file_sink_base.cc
+++ b/gr-blocks/lib/file_sink_base.cc
@@ -13,6 +13,7 @@
#endif
#include <gnuradio/blocks/file_sink_base.h>
+#include <gnuradio/logger.h>
#include <gnuradio/thread/thread.h>
#include <fcntl.h>
#include <stdio.h>
@@ -46,6 +47,7 @@ file_sink_base::file_sink_base(const char* filename, bool is_binary, bool append
{
if (!open(filename))
throw std::runtime_error("can't open file");
+ gr::configure_default_loggers(d_logger, d_debug_logger, "file_sink_base");
}
file_sink_base::~file_sink_base()
@@ -64,13 +66,14 @@ bool file_sink_base::open(const char* filename)
// we use the open system call to get access to the O_LARGEFILE flag.
int fd;
int flags;
+
if (d_append) {
flags = O_WRONLY | O_CREAT | O_APPEND | OUR_O_LARGEFILE | OUR_O_BINARY;
} else {
flags = O_WRONLY | O_CREAT | O_TRUNC | OUR_O_LARGEFILE | OUR_O_BINARY;
}
if ((fd = ::open(filename, flags, 0664)) < 0) {
- perror(filename);
+ GR_LOG_ERROR(d_logger, boost::format("%s: %s") % filename % strerror(errno));
return false;
}
if (d_new_fp) { // if we've already got a new one open, close it
@@ -79,7 +82,7 @@ bool file_sink_base::open(const char* filename)
}
if ((d_new_fp = fdopen(fd, d_is_binary ? "wb" : "w")) == NULL) {
- perror(filename);
+ GR_LOG_ERROR(d_logger, boost::format("%s: %s") % filename % strerror(errno));
::close(fd); // don't leak file descriptor if fdopen fails.
}