summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/log/OstreamOutput.cpp
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2008-10-15 22:33:34 +0000
committerStephen D. Huston <shuston@apache.org>2008-10-15 22:33:34 +0000
commit708790b9914b97404974860f0b801b720dd7a0ec (patch)
tree7f192e792e4c27d7930a64b2387203b2349dff30 /cpp/src/qpid/log/OstreamOutput.cpp
parent8cdf7df6f7690b0fc789ad2a9735299953384daf (diff)
downloadqpid-python-708790b9914b97404974860f0b801b720dd7a0ec.tar.gz
Split logging options into portable options and sink-related options that are platform-specific. Re-did sink options for Posix as discussed on qpid-dev (no more --log-output, but more specific --log-to-<target> options. Allows addition of Windows options without further reorg of Posix code.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@705083 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/log/OstreamOutput.cpp')
-rw-r--r--cpp/src/qpid/log/OstreamOutput.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/cpp/src/qpid/log/OstreamOutput.cpp b/cpp/src/qpid/log/OstreamOutput.cpp
new file mode 100644
index 0000000000..c96a311a4e
--- /dev/null
+++ b/cpp/src/qpid/log/OstreamOutput.cpp
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "OstreamOutput.h"
+#include <stdexcept>
+
+using namespace std;
+
+namespace qpid {
+namespace log {
+
+OstreamOutput::OstreamOutput(std::ostream& o) : out(&o) {}
+
+OstreamOutput::OstreamOutput(const std::string& file)
+ : out(new ofstream(file.c_str(), ios_base::out | ios_base::app)),
+ mine(out)
+{
+ if (!out->good())
+ throw std::runtime_error("Can't open log file: "+file);
+}
+
+void OstreamOutput::log(const Statement&, const std::string& m) {
+ *out << m << flush;
+}
+
+}} // namespace qpid::log