libassa 3.5.1
Loading...
Searching...
No Matches
StdOutLogger.cpp
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// StdOutLogger.cpp
4//------------------------------------------------------------------------------
5// $Id: StdOutLogger.cpp,v 1.4 2006/07/20 02:30:54 vlg Exp $
6//------------------------------------------------------------------------------
7// Copyright (c) 2001 by Vladislav Grinchenko
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Library General Public
11// License as published by the Free Software Foundation; either
12// version 2 of the License, or (at your option) any later version.
13//
14//------------------------------------------------------------------------------
15// Created: 10/31/2001
16//------------------------------------------------------------------------------
17#include <stdio.h>
18#include <stdarg.h> // vsprintf(3)
19#include <string>
20#include <iomanip>
21
22#include "assa/StdOutLogger.h"
23
24using namespace ASSA;
25
26int
29 size_t indent_level_,
30 const string& func_name_,
31 size_t expected_sz_,
32 const char* fmt_,
34{
35 bool release = false;
36 char* msgbuf_ptr = NULL;
37
38 if (! group_enabled (g_)) {
39 return 0;
40 }
41
42 add_timestamp (std::cerr);
44
46
47 if (msgbuf_ptr == NULL) {
48 return -1; // failed to format
49 }
50 std::cout << msgbuf_ptr;
51
52 if (release) {
53 delete [] msgbuf_ptr;
54 }
55 return 0;
56}
57
58int
61 size_t indent_level_,
62 const string& func_name_,
64{
65 if (! group_enabled (g_)) {
66 return 0;
67 }
68
69 add_timestamp (std::cerr);
71
72 if (type_ == FUNC_ENTRY) {
73 std::cout << "---v---\n";
74 }
75 else if (type_ == FUNC_EXIT) {
76 std::cout << "---^---\n";
77 }
78
79 return 0;
80}
81
StdOutLogger implements Logger as standard output.
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
char * format_msg(size_t expected_sz_, const char *fmt_, va_list vap_, bool &release_)
Format and put the message in the buffer.
virtual u_short indent_func_name(ostream &sink_, const string &funcname_, size_t indent_level_, marker_t type_)
bool group_enabled(Group g_) const
virtual u_short add_timestamp(ostream &sink_)
virtual int log_msg(Group g_, size_t indent_level_, const string &func_name_, size_t expected_sz_, const char *fmt_, va_list)
virtual int log_func(Group g_, size_t indent_level_, const string &func_name_, marker_t type_)
marker_t
Definition LogMask.h:67
@ FUNC_ENTRY
Definition LogMask.h:69
@ FUNC_MSG
Definition LogMask.h:68
@ FUNC_EXIT
Definition LogMask.h:70
Group
Definition LogMask.h:25