summaryrefslogtreecommitdiff
path: root/modules/CIAO/ciao/Logger/File_Logger_Backend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/CIAO/ciao/Logger/File_Logger_Backend.cpp')
-rw-r--r--modules/CIAO/ciao/Logger/File_Logger_Backend.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/modules/CIAO/ciao/Logger/File_Logger_Backend.cpp b/modules/CIAO/ciao/Logger/File_Logger_Backend.cpp
new file mode 100644
index 00000000000..b4a25d0d1b1
--- /dev/null
+++ b/modules/CIAO/ciao/Logger/File_Logger_Backend.cpp
@@ -0,0 +1,46 @@
+// $Id$
+#include "File_Logger_Backend.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/Log_Record.h"
+#include "ace/Log_Msg.h"
+#include "ciao/CIAO_common.h"
+
+namespace CIAO
+{
+
+ int
+ File_Logger_Backend::open (const ACE_TCHAR *)
+ {
+ CIAO_DEBUG ( (LM_DEBUG, CLINFO "Setting logger's output to file \"%s\"", this->filename_.c_str()));
+ this->fh_ = ACE_OS::fopen (this->filename_.c_str(), "w");
+ if (0 == this->fh_)
+ {
+ ACE_CString s = "Failed to open log file \"";
+ s += ACE_TEXT_ALWAYS_CHAR (this->filename_.c_str ());
+ s += "\"";
+ throw LoggerError (s.c_str());
+ }
+ return 0;
+ }
+
+ int
+ File_Logger_Backend::close (void)
+ {
+ if (0 != this->fh_)
+ {
+ ACE_OS::fclose (this->fh_);
+ this->fh_ = 0;
+ }
+ return 0;
+ }
+
+ ssize_t
+ File_Logger_Backend::log (ACE_Log_Record &log_record)
+ {
+ int res = log_record.print (0, ACE_Log_Msg::VERBOSE, this->fh_);
+ ACE_OS::fflush (this->fh_);
+ return res;
+ }
+
+}
+