source: ThirdParty/CodePatterns/src/Helpers/logger.cpp@ 6458e7

AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator Exclude_Hydrogens_annealWithBondGraph ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity PythonUI_with_named_parameters StoppableMakroAction TremoloParser_IncreasedPrecision
Last change on this file since 6458e7 was 9eb71b3, checked in by Frederik Heber <frederik.heber@…>, 8 years ago

Commented out MemDebug include and Memory::ignore.

  • MemDebug clashes with various allocation operators that use a specific placement in memory. It is so far not possible to wrap new/delete fully. Hence, we stop this effort which so far has forced us to put ever more includes (with clashes) into MemDebug and thereby bloat compilation time.
  • MemDebug does not add that much usefulness which is not also provided by valgrind.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * logger.cpp
10 *
11 * Created on: Oct 19, 2009
12 * Author: metzler
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20//#include "CodePatterns/MemDebug.hpp"
21
22#include <fstream>
23#include <iostream>
24#include "CodePatterns/logger.hpp"
25#include "CodePatterns/Verbose.hpp"
26#include "CodePatterns/Singleton_impl.hpp"
27
28
29int logger::verbosity = 2;
30ostream* logger::nix = NULL;
31ostream* logger::defaultout = NULL;
32ostream* logger::out = NULL;
33
34/**
35 * Constructor. Do not use this function. Use getInstance() instead.
36 *
37 * \return logger instance
38 */
39logger::logger()
40{
41 nix = new ofstream("/dev/null");
42 defaultout = &cout;
43 out = defaultout;
44};
45
46/**
47 * Destructor. Better use purgeInstance().
48 */
49logger::~logger()
50{
51 delete nix;
52 out = NULL; // we are not responsible if out got changed
53 defaultout = NULL; // do not delete cout
54}
55
56CONSTRUCT_SINGLETON(logger)
57
58/**
59 * Sets the verbosity.
60 *
61 * \param verbosityLevel verbosity
62 */
63void logger::setVerbosity(int verbosityLevel) {
64 verbosity = verbosityLevel;
65}
66
67/**
68 * Gets the verbosity.
69 *
70 * \return verbosity level
71 */
72int logger::getVerbosity()
73{
74 return verbosity;
75}
76
77/** Sets a new output stream.
78 *
79 * \param _newout new output stream, if NULL we set to defaultout
80 */
81void logger::setOutputStream(ostream *_newout)
82{
83 if(_newout != NULL)
84 out = _newout;
85 else
86 out = defaultout;
87}
88
89/**
90 * Operator for the Binary(arg) call.
91 * Constructs temporary a Verbose class object, wherein the Binary is stored.
92 * Then << is called, which calls Binary's print which adds the tabs and logs
93 * the stream.
94 * \param &ost stream to extend
95 * \param &m pointer to created Binary object
96 * \return &ost
97 */
98ostream& operator<<(class logger& l, const Verbose& v)
99{
100 int verbosityLevel = l.verbosity;
101 l.nix->clear();
102 if (v.DoOutput(verbosityLevel)) {
103 v.print(*logger::out);
104 return *logger::out;
105 } else
106 return *l.nix;
107};
108ostream& operator<<(class logger* l, const Verbose& v)
109{
110 int verbosityLevel = l->verbosity;
111 l->nix->clear();
112 if (v.DoOutput(verbosityLevel)) {
113 v.print(*logger::out);
114 return *logger::out;
115 } else
116 return *l->nix;
117};
118
Note: See TracBrowser for help on using the repository browser.