/build/buildd/libassa-3.4.1/assa/StdOutLogger.cpp

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //------------------------------------------------------------------------------
00003 //                              StdOutLogger.cpp
00004 //------------------------------------------------------------------------------
00005 // $Id: StdOutLogger.cpp,v 1.3 2003/07/25 02:51:47 vlg Exp $
00006 //------------------------------------------------------------------------------
00007 //  Copyright (c) 2001 by Vladislav Grinchenko
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Library General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2 of the License, or (at your option) any later version.
00013 //
00014 //------------------------------------------------------------------------------
00015 //  Created: 10/31/2001
00016 //------------------------------------------------------------------------------
00017 #include <stdio.h>
00018 #include <stdarg.h>             // vsprintf(3)
00019 #include <string>
00020 #include <iomanip>
00021 
00022 #include "assa/StdOutLogger.h"
00023 
00024 using namespace ASSA;
00025 
00026 int
00027 StdOutLogger::
00028 log_msg (Group                    g_,
00029          size_t        indent_level_, 
00030          const string&    func_name_,
00031          size_t         expected_sz_,
00032          const char*            fmt_,
00033          va_list           msg_list_)
00034 {
00035     if (! group_enabled (g_)) {
00036         return 0;
00037     }
00038 
00039     add_timestamp (std::cerr);
00040     indent_func_name (std::cerr, func_name_, indent_level_, FUNC_MSG);
00041 
00042     bool release = false;
00043     char* msgbuf_ptr = format_msg (expected_sz_, fmt_, msg_list_, release);
00044     if (msgbuf_ptr == NULL) {
00045         return -1;              // failed to format
00046     }
00047     std::cout << msgbuf_ptr;
00048 
00049     if (release) {
00050         delete [] msgbuf_ptr;
00051     }
00052     return 0;
00053 }
00054 
00055 int
00056 StdOutLogger::
00057 log_func (Group g_, size_t indent_level_, const string& func_name_,
00058           marker_t type_) 
00059 {
00060     if (! group_enabled (g_)) {
00061         return 0;
00062     }
00063 
00064     add_timestamp (std::cerr);
00065     indent_func_name (std::cout, func_name_, indent_level_, type_);
00066 
00067     if (type_ == FUNC_ENTRY) {
00068         std::cout << "---v---\n";
00069     }
00070     else if (type_ == FUNC_EXIT) {
00071         std::cout << "---^---\n";
00072     }
00073     
00074     return 0;
00075 }
00076 

Generated on Tue Jun 20 10:36:21 2006 for libassa by  doxygen 1.4.6