From 6afc10c3e53625b06163011476d77c1b005c171a Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Sun, 7 Dec 2003 23:25:49 +0000 Subject: initial check-in --- cpp/demo/Ice/MFC/server/LogI.cpp | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 cpp/demo/Ice/MFC/server/LogI.cpp (limited to 'cpp/demo/Ice/MFC/server/LogI.cpp') diff --git a/cpp/demo/Ice/MFC/server/LogI.cpp b/cpp/demo/Ice/MFC/server/LogI.cpp new file mode 100644 index 00000000000..58b6f3b7265 --- /dev/null +++ b/cpp/demo/Ice/MFC/server/LogI.cpp @@ -0,0 +1,76 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +#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(); + } +} -- cgit v1.2.3