------------------------------------------------------------
revno: 10
committer: fpstov...@gmail.com
branch nick: dev
timestamp: Sun 2010-12-26 22:55:39 -0500
message:
  Completed the global logging setup function and unit test program. All seems 
to be working properly.
added:
  common/logger/Makefile
  common/logger/log_setup.cpp
  common/logger/log_setup.h
  common/logger/log_test.cpp


--
lp:~fpstovall/nrtb/cpp_common
https://code.launchpad.net/~fpstovall/nrtb/cpp_common

Your team NRTB Core is subscribed to branch lp:~fpstovall/nrtb/cpp_common.
To unsubscribe from this branch go to 
https://code.launchpad.net/~fpstovall/nrtb/cpp_common/+edit-subscription
=== added file 'common/logger/Makefile'
--- common/logger/Makefile	1970-01-01 00:00:00 +0000
+++ common/logger/Makefile	2010-12-27 03:55:39 +0000
@@ -0,0 +1,39 @@
+#***********************************************
+#This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+#    NRTB is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    NRTB is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with NRTB.  If not, see <http://www.gnu.org/licenses/>.
+#
+#***********************************************
+
+build:	log_test Makefile
+	@echo build complete
+
+log_setup.o:	log_setup.h log_setup.cpp Makefile
+	@rm -f log_setup.o
+	g++ -c log_setup.cpp -I ../include
+
+log_test:	log_setup.o log_test.cpp Makefile
+	@rm -vf log_test
+	g++ -c log_test.cpp -I../include 
+	g++ -o log_test log_setup.o log_test.o -lPocoFoundation
+#	g++ -g common_test.cpp  -idirafter . -o common_test
+
+clean:
+	@rm -vf *.o log_test ../include/log_setup.h ../obj/log_setup.o
+
+lib:	log_test
+	@cp -fv log_setup.h ../include
+	@cp -fv log_setup.o ../obj
+
+

=== added file 'common/logger/log_setup.cpp'
--- common/logger/log_setup.cpp	1970-01-01 00:00:00 +0000
+++ common/logger/log_setup.cpp	2010-12-27 03:55:39 +0000
@@ -0,0 +1,43 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+ 
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with NRTB.  If not, see <http://www.gnu.org/licenses/>.
+ 
+ **********************************************/
+ 
+#include "log_setup.h"
+
+#include "Poco/SimpleFileChannel.h"
+#include "Poco/FormattingChannel.h"
+#include "Poco/PatternFormatter.h"
+#include "Poco/Logger.h"
+#include "Poco/AutoPtr.h"
+
+using Poco::SimpleFileChannel;
+using Poco::FormattingChannel;
+using Poco::PatternFormatter;
+using Poco::Logger;
+using Poco::AutoPtr;
+
+void nrtb::setup_global_logging(const std::string & logfilename)
+{
+  AutoPtr<SimpleFileChannel> pFile(new SimpleFileChannel);
+  pFile->setProperty("path", logfilename);
+  pFile->setProperty("rotation", "2 K");
+  AutoPtr<PatternFormatter> pPF(new PatternFormatter);
+  pPF->setProperty("pattern", "%Y-%m-%d %H:%M:%S %s: %t");
+  AutoPtr<FormattingChannel> pFC(new FormattingChannel(pPF, pFile));
+  Logger::root().setChannel(pFC);
+  Logger::root().notice("Logging system initialized");
+}
\ No newline at end of file

=== added file 'common/logger/log_setup.h'
--- common/logger/log_setup.h	1970-01-01 00:00:00 +0000
+++ common/logger/log_setup.h	2010-12-27 03:55:39 +0000
@@ -0,0 +1,30 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+ 
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with NRTB.  If not, see <http://www.gnu.org/licenses/>.
+ 
+ **********************************************/
+ 
+#ifndef logger_setup_h
+#define logger_setup_h
+
+#include <string>
+
+namespace nrtb
+{
+
+  void setup_global_logging(const std::string & logfilename);
+}
+
+#endif //logger_setup_h
\ No newline at end of file

=== added file 'common/logger/log_test.cpp'
--- common/logger/log_test.cpp	1970-01-01 00:00:00 +0000
+++ common/logger/log_test.cpp	2010-12-27 03:55:39 +0000
@@ -0,0 +1,35 @@
+/***********************************************
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+ 
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with NRTB.  If not, see <http://www.gnu.org/licenses/>.
+ 
+ **********************************************/
+ 
+#include "log_setup.h"
+
+#include <string>
+#include <Poco/Logger.h>
+#include "Poco/LogStream.h"
+
+using namespace std;
+
+int main()
+{
+  nrtb::setup_global_logging("test_ouput.log");
+  Poco::Logger & logger = Poco::Logger::get("log_test");
+  logger.notice("Logging should be set up now.");
+  Poco::LogStream log(logger);
+  log << "This message used the stream interface" << endl;
+  logger.fatal("Program run complete.");
+}

_______________________________________________
Mailing list: https://launchpad.net/~nrtb-core
Post to     : nrtb-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~nrtb-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to