blob: ace1b31db964c4be3d7724fef4adb4cf4e46bc98 (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2003 - 2004
// ZeroC, Inc.
// North Palm Beach, FL, USA
//
// All Rights Reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include "stdafx.h"
#include "LogI.h"
using namespace std;
LogI::LogI() :
_log(0)
{
}
void
LogI::trace(const string& category, const string& msg)
{
string s = "[ " + category + ": " + msg + " ]";
string::size_type idx = 0;
while((idx = s.find("\n", idx)) != string::npos)
{
s.replace(idx, 1, "\r\n ");
idx += 3;
}
message(s);
}
void
LogI::warning(const string& msg)
{
message("warning: " + msg);
}
void
LogI::error(const string& msg)
{
message("error: " + msg);
}
void
LogI::message(const string& msg)
{
string line = msg + "\r\n";
if(_log)
{
_log->SetSel(-1, -1);
_log->ReplaceSel(CString(line.c_str()));
}
else
{
_buffer.append(line);
}
}
void
LogI::setControl(CEdit* log)
{
_log = log;
if(!_buffer.empty())
{
_log->ReplaceSel(CString(_buffer.c_str()));
_buffer.clear();
}
}
|