[go: up one dir, main page]

Menu

[r189]: / tags / 0.9 / porg / out.cc  Maximize  Restore  History

Download this file

60 lines (45 with data), 1.2 kB

 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
//=======================================================================
// out.cc
//-----------------------------------------------------------------------
// This file is part of the package porg
// Copyright (C) 2015 David Ricart
// For more information visit http://porg.sourceforge.net
//=======================================================================
#include "config.h"
#include "out.h"
#include <string>
using std::string;
using std::cerr;
using namespace Porg;
int Out::s_verbosity = QUIET;
void Out::vrb(string const& msg, int errno_ /* = 0 */)
{
if (verbose()) {
if (errno_)
cerr << "porg: " << msg << ": " << strerror(errno_) << "\n";
else
cerr << msg << "\n";
}
}
void Out::dbg(string const& msg, bool print_prog_name /* = true */)
{
if (debug())
cerr << (print_prog_name ? "porg :: " : "") << msg << '\n';
}
void Out::dbg_title(string const& title /* = "" */)
{
if (!debug())
return;
string head("porg :: ----");
cerr << head;
int cnt = head.size();
if (title.size()) {
string str(string("[ ") + title + " ]");
cerr << str;
cnt += str.size();
}
int width = DEFAULT_SCREEN_WIDTH;
if (width > cnt)
cerr << string(width - cnt, '-');
cerr << '\n';
}