/home/vlg/develop/libASSA/libassa/assa/StdOutLogger.cpp

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //------------------------------------------------------------------------------
00003 //                              StdOutLogger.cpp
00004 //------------------------------------------------------------------------------
00005 // $Id: StdOutLogger.cpp,v 1.4 2006/07/20 02:30:54 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     bool release = false;
00036     char* msgbuf_ptr = NULL;
00037 
00038     if (! group_enabled (g_)) {
00039         return 0;
00040     }
00041 
00042     add_timestamp (std::cerr);
00043     indent_func_name (std::cerr, func_name_, indent_level_, FUNC_MSG);
00044 
00045     msgbuf_ptr = format_msg (expected_sz_, fmt_, msg_list_, release);
00046 
00047     if (msgbuf_ptr == NULL) {
00048         return -1;              // failed to format
00049     }
00050     std::cout << msgbuf_ptr;
00051 
00052     if (release) {
00053         delete [] msgbuf_ptr;
00054     }
00055     return 0;
00056 }
00057 
00058 int
00059 StdOutLogger::
00060 log_func (Group         g_, 
00061           size_t        indent_level_, 
00062           const string& func_name_,
00063           marker_t      type_) 
00064 {
00065     if (! group_enabled (g_)) {
00066         return 0;
00067     }
00068 
00069     add_timestamp (std::cerr);
00070     indent_func_name (std::cout, func_name_, indent_level_, type_);
00071 
00072     if (type_ == FUNC_ENTRY) {
00073         std::cout << "---v---\n";
00074     }
00075     else if (type_ == FUNC_EXIT) {
00076         std::cout << "---^---\n";
00077     }
00078     
00079     return 0;
00080 }
00081 

Generated on Sun Aug 13 15:08:00 2006 for libassa by  doxygen 1.4.6