File: StdOutLogger.cpp

package info (click to toggle)
libassa 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,084 kB
  • ctags: 2,323
  • sloc: cpp: 15,641; sh: 8,704; makefile: 372; perl: 51
file content (81 lines) | stat: -rw-r--r-- 2,079 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// -*- 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;
}