-// ANNA - Anna is Not 'N' Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// https://bitbucket.org/testillano/anna
-//
-// 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 Google Inc. 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>
#include <anna/core/tracing/TraceWriter.hpp>
#include <anna/core/DataBlock.hpp>
#include <anna/core/functions.hpp>
-#include <anna/core/Configuration.hpp>
+#include <anna/core/util/Configuration.hpp>
#include <anna/core/tracing/TraceWriterObserver.hpp>
using namespace std;
}
void TraceWriter::setup(const char* fileName, const Configuration& configuration)
-throw() {
+{
int maxSize = a_maxSize;
bool clean = true;
}
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) {
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");
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);
}
void TraceWriter::printResume()
-throw() {
+{
cout << "Traces file ..................................: " << a_outputFile << endl;
cout << "Backup copy .................................: " << a_outputOldFile << endl;
cout << "Files size (Kbytes) ..........................: " << (a_maxSize >> 10) << endl;
}
void TraceWriter::do_write(int level, const char* text, ...)
-throw() {
+{
va_list ap;
const char* data;
int size;
}
const char* TraceWriter::getDate()
-throw() {
+{
const Microsecond msnow = functions::hardwareClock();
if(a_lastTime == 0 || (msnow - a_lastTime) > 1000000L) {
}
int TraceWriter::prepareOutput(const char* date)
-throw() {
+{
int result = a_stream;
if(result == ErrorStream)