Loading...
Searching...
No Matches
StdOutLogger.cpp
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// StdOutLogger.cpp
//------------------------------------------------------------------------------
// $Id: StdOutLogger.cpp,v 1.4 2006/07/20 02:30:54 vlg Exp $
//------------------------------------------------------------------------------
// Copyright (c) 2001 by Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
//------------------------------------------------------------------------------
// Created: 10/31/2001
//------------------------------------------------------------------------------
#include <stdio.h>
#include <stdarg.h> // vsprintf(3)
#include <string>
#include <iomanip>
#include "assa/StdOutLogger.h"
using namespace ASSA;
int
StdOutLogger::
log_msg (Group g_,
size_t indent_level_,
const string& func_name_,
size_t expected_sz_,
const char* fmt_,
va_list msg_list_)
{
bool release = false;
char* msgbuf_ptr = NULL;
if (! group_enabled (g_)) {
return 0;
}
add_timestamp (std::cerr);
indent_func_name (std::cerr, func_name_, indent_level_, FUNC_MSG);
msgbuf_ptr = format_msg (expected_sz_, fmt_, msg_list_, release);
if (msgbuf_ptr == NULL) {
return -1; // failed to format
}
std::cout << msgbuf_ptr;
if (release) {
delete [] msgbuf_ptr;
}
return 0;
}
int
StdOutLogger::
log_func (Group g_,
size_t indent_level_,
const string& func_name_,
marker_t type_)
{
if (! group_enabled (g_)) {
return 0;
}
add_timestamp (std::cerr);
indent_func_name (std::cout, func_name_, indent_level_, type_);
if (type_ == FUNC_ENTRY) {
std::cout << "---v---\n";
}
else if (type_ == FUNC_EXIT) {
std::cout << "---^---\n";
}
return 0;
}
StdOutLogger.h
StdOutLogger implements Logger as standard output.
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::Logger_Impl::format_msg
char * format_msg(size_t expected_sz_, const char *fmt_, va_list vap_, bool &release_)
Format and put the message in the buffer.
Definition Logger_Impl.cpp:86
ASSA::Logger_Impl::indent_func_name
virtual u_short indent_func_name(ostream &sink_, const string &funcname_, size_t indent_level_, marker_t type_)
Definition Logger_Impl.cpp:54
ASSA::Logger_Impl::group_enabled
bool group_enabled(Group g_) const
Definition Logger_Impl.h:164
ASSA::Logger_Impl::add_timestamp
virtual u_short add_timestamp(ostream &sink_)
Definition Logger_Impl.cpp:35
ASSA::StdOutLogger::log_msg
virtual int log_msg(Group g_, size_t indent_level_, const string &func_name_, size_t expected_sz_, const char *fmt_, va_list)
Definition StdOutLogger.cpp:28
ASSA::StdOutLogger::log_func
virtual int log_func(Group g_, size_t indent_level_, const string &func_name_, marker_t type_)
Definition StdOutLogger.cpp:60
ASSA
Definition Acceptor.h:40
ASSA::marker_t
marker_t
Definition LogMask.h:67
ASSA::FUNC_ENTRY
@ FUNC_ENTRY
Definition LogMask.h:69
ASSA::FUNC_MSG
@ FUNC_MSG
Definition LogMask.h:68
ASSA::FUNC_EXIT
@ FUNC_EXIT
Definition LogMask.h:70
ASSA::Group
Group
Definition LogMask.h:25