|
a/sc2src/log.cpp |
|
b/sc2src/log.cpp |
|
... |
|
... |
12 |
* You should have received a copy of the GNU General Public License
|
12 |
* You should have received a copy of the GNU General Public License
|
13 |
* along with this program; if not, write to the
|
13 |
* along with this program; if not, write to the
|
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#include "config.h"
|
|
|
18 |
|
17 |
|
19 |
#include "log.h"
|
18 |
#include "log.h"
|
20 |
|
19 |
|
21 |
#include <errno.h> // for errno
|
20 |
#include <errno.h>
|
22 |
|
21 |
#include <fstream>
|
23 |
#include <fstream> // for operator<<, basic_ostream, etc
|
|
|
24 |
|
22 |
|
25 |
using namespace std;
|
23 |
using namespace std;
|
26 |
|
24 |
|
27 |
|
|
|
28 |
Logger::Logger(const std::string& fn)
|
25 |
Logger::Logger(const std::string& fn)
|
29 |
: m_tocerr(false), m_loglevel(LLDEB)
|
26 |
: m_tocerr(false), m_loglevel(LLDEB)
|
30 |
{
|
27 |
{
|
31 |
if (!fn.empty() && fn.compare("stderr")) {
|
28 |
if (!fn.empty() && fn.compare("stderr")) {
|
32 |
m_stream.open(fn, std::fstream::out | std::ofstream::trunc);
|
29 |
m_stream.open(fn.c_str(), std::fstream::out | std::ofstream::trunc);
|
33 |
if (!m_stream.is_open()) {
|
30 |
if (!m_stream.is_open()) {
|
34 |
cerr << "Logger::Logger: log open failed: for [" <<
|
31 |
cerr << "Logger::Logger: log open failed: for [" <<
|
35 |
fn << "] errno " << errno << endl;
|
32 |
fn << "] errno " << errno << endl;
|
36 |
m_tocerr = true;
|
33 |
m_tocerr = true;
|
37 |
}
|
34 |
}
|
38 |
} else {
|
35 |
} else {
|
39 |
m_tocerr = true;
|
36 |
m_tocerr = true;
|
40 |
}
|
37 |
}
|