Remove dynamic exceptions
[anna.git] / source / core / tracing / TraceWriter.cpp
index a4b9981..6111526 100644 (file)
@@ -1,37 +1,9 @@
-// ANNA - Anna is Not Nothingness Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// http://redmine.teslayout.com/projects/anna-suite
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     *  Neither the name of the copyright holder nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: eduardo.ramos.testillano@gmail.com
-//          cisco.tierra@gmail.com
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
 
 
 #include <stdarg.h>
@@ -75,7 +47,7 @@ TraceWriter::TraceWriter(const char* fileName, const int maxSize) :
 }
 
 void TraceWriter::setup(const char* fileName, const Configuration& configuration)
-throw() {
+{
   int maxSize = a_maxSize;
   bool clean = true;
 
@@ -102,13 +74,15 @@ throw() {
 }
 
 void TraceWriter::setup(const char* fileName, const int maxSize, const bool clean)
-throw() {
+{
+  ssize_t r;
+
   if(a_stream != -1) {
     if(clean == false) {
       string msg("\nTraces go on at: ");
       msg += fileName;
       msg += '\n';
-      write(a_stream, msg.c_str(), msg.length());
+      r = write(a_stream, msg.c_str(), msg.length());
     }
 
     if(a_observed == true) {
@@ -132,7 +106,6 @@ throw() {
   if(maxSize >= (256 * 1024))
     a_maxSize = maxSize;
 
-  const char* aux = Logger::asString(Logger::getLevel());
   char date [anna::functions::DateTimeSizeString + 7];
   anna_strcpy(date, "- [");
   anna_strcat(anna_strcat(date, getDate()), "]\n");
@@ -141,20 +114,20 @@ throw() {
   if(stream != ErrorStream) {
     const char* aux = "\n--------------------------------------------------------------\n";
     const char* aux2 = "- Current trace level: ";
-    write(stream, aux, anna_strlen(aux));
-    write(stream, date, anna_strlen(date));
-    write(stream, aux2, anna_strlen(aux2));
+    r = write(stream, aux, anna_strlen(aux));
+    r = write(stream, date, anna_strlen(date));
+    r = write(stream, aux2, anna_strlen(aux2));
     aux2 = Logger::asString(Logger::getLevel());
-    write(stream, aux2, anna_strlen(aux2));
+    r = write(stream, aux2, anna_strlen(aux2));
     string filesize = functions::asString("\n- Max file size : %d Kb", a_maxSize >> 10);
     aux2 = filesize.c_str();
-    write(stream, aux2, anna_strlen(aux2));
-    write(stream, aux, anna_strlen(aux));
+    r = write(stream, aux2, anna_strlen(aux2));
+    r = write(stream, aux, anna_strlen(aux));
   }
 }
 
 void TraceWriter::attach(TraceWriterObserver* observer)
-throw() {
+{
   if(observer != NULL) {
     a_observed = true;
     a_observers.push_back(observer);
@@ -165,7 +138,7 @@ throw() {
 }
 
 void TraceWriter::printResume()
-throw() {
+{
   cout << "Traces file ..................................: " << a_outputFile << endl;
   cout << "Backup copy  .................................: " << a_outputOldFile << endl;
   cout << "Files size (Kbytes) ..........................: " << (a_maxSize >> 10) << endl;
@@ -173,7 +146,7 @@ throw() {
 }
 
 void TraceWriter::do_write(int level, const char* text, ...)
-throw() {
+{
   va_list ap;
   const char* data;
   int size;
@@ -228,7 +201,7 @@ throw() {
 }
 
 const char* TraceWriter::getDate()
-throw() {
+{
   const Microsecond msnow = functions::hardwareClock();
 
   if(a_lastTime == 0 || (msnow - a_lastTime) > 1000000L) {
@@ -241,7 +214,7 @@ throw() {
 }
 
 int TraceWriter::prepareOutput(const char* date)
-throw() {
+{
   int result = a_stream;
 
   if(result == ErrorStream)