]>
cygwin.com Git - cygwin-apps/setup.git/blob - LogSingleton.cc
2 * Copyright (c) 2002, Robert Collins..
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 #include "LogSingleton.h"
19 /* Helper functions */
21 /* End of a Log comment */
22 ostream
& endLog(ostream
& outs
)
24 /* Doesn't seem to be any way around this */
25 dynamic_cast<LogSingleton
&>(outs
).endEntry();
29 /* The LogSingleton class */
31 LogSingleton
* LogSingleton::theInstance(0);
33 LogSingleton::LogSingleton(){}
34 LogSingleton::~LogSingleton(){}
37 LogSingleton::GetInstance()
40 throw new invalid_argument ("No instance has been set!");
45 LogSingleton::SetInstance(LogSingleton
&newInstance
)
47 theInstance
= &newInstance
;
51 // Logging class. Default logging level is PLAIN.
52 class LogSingleton
: public ostream
56 /* Some platforms don't call destructors. So this call exists
57 * which guarantees to flush any log data...
58 * but doesn't call generic C++ destructors
60 virtual void exit (int const exit_code
) __attribute__ ((noreturn
));
61 // get a specific verbosity stream.
62 virtual ostream
&operator() (enum log_level level
);
64 friend ostream
& endLog(ostream
& outs
);
67 LogSingleton (LogSingleton
const &); // no copy constructor
68 LogSingleton
&operator = (LogSingleton
const&); // no assignment operator
69 void endEntry(); // the current in-progress entry is complete.
71 static LogSingleton
*theInstance
;
This page took 0.038381 seconds and 5 git commands to generate.