*Core: Config->Ini

git-svn-id: svn://ultimatepp.org/upp/trunk@5098 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-07-03 07:47:35 +00:00
parent 19b4bcee96
commit cac41a45bc
4 changed files with 9 additions and 112 deletions

View file

@ -167,13 +167,13 @@ struct DebugLogBlock
// USRLOG
struct IniBool;
namespace Ini {
extern IniBool user_log;
struct Bool;
extern Bool user_log;
};
#define USRLOG(x) LOG_(Config::user_log, x)
#define USRLOG(x) LOG_(Ini::user_log, x)
// Crash support

View file

@ -447,111 +447,8 @@ void SetVppLogName(const String& file) {
ReopenLog();
}
namespace Config {
INI_BOOL(user_log, false, "Activates logging of user actions");
namespace Ini {
INI_BOOL(user_log, false, "Activates logging of user actions");
};
Stream& BugLog()
{
return VppLog();
/*
if(snobuglog)
return NilStream();
static LogStream *s;
if(!s) {
INTERLOCKED
if(!s) {
static byte lb[sizeof(LogStream)];
s = new(lb) LogStream;
char h[200];
sTime(h, ".buglog");
s->Create(h, false);
}
}
return *s;
*/
}
bool susrlog;
bool susrlogpersistent;
void ActivateUsrLog()
{
VppLog();
susrlog = true;
}
void ActivatePersistentUsrLog()
{
ActivateUsrLog();
susrlogpersistent = true;
}
Stream& UsrLog()
{
return susrlog ? (Stream&)VppLog() : NilStream();
}
Stream& UsrLog(const char *line)
{
if(!susrlog)
return NilStream();
return UsrLog() << line << "\r\n";
}
Stream& UsrLogT(int indent, const char *line)
{
if(!susrlog)
return NilStream();
Time tm = GetSysTime();
char h[256];
sprintf(h, "%02d:%02d:%02d ", tm.hour, tm.minute, tm.second);
Stream& s = VppLog() << h;
while(indent--)
s << " ";
s << line << "\r\n";
return s;
}
Stream& UsrLogT(const char *line)
{
return UsrLogT(0, line);
}
bool IsUsrLog()
{
return susrlog;
}
void DeleteUsrLog()
{
if(susrlogpersistent) {
if(susrlog)
VppLog() << "log is persistent";
}
else {
// if(susrlog && !StdLogStream().Delete())
// LOG("Unable to delete UsrLog, " << GetLastErrorMessage());
susrlog = false;
}
}
/*
void sTime(char *h, const char *ext)
{
Time t = GetSysTime();
char th[200];
sprintf(th, ".%d-%02d-%02d-%02d-%02d-%02d", t.year, t.month, t.day, t.hour, t.minute, t.second);
strcat(th, ext);
sLogFile(h, th);
}
*/
bool snobuglog;
void DeactivateBugLog()
{
snobuglog = true;
}
END_UPP_NAMESPACE

View file

@ -69,7 +69,7 @@ bool Ctrl::DispatchKey(dword keycode, int count)
if(!focusCtrl)
return false;
Ptr<Ctrl> p = focusCtrl;
if(Config::user_log) {
if(Ini::user_log) {
String kl;
dword k = keycode;
const char *l = "";
@ -94,7 +94,7 @@ bool Ctrl::DispatchKey(dword keycode, int count)
{
LLOG("Ctrl::DispatchKey(" << FormatIntHex(keycode) << ", " << GetKeyDesc(keycode)
<< "): eaten in " << Desc(p));
if(Config::user_log)
if(Ini::user_log)
USRLOG(" -> " << Desc(p));
eventCtrl = focusCtrl;
return true;
@ -123,7 +123,7 @@ bool Ctrl::HotKey(dword key)
{
if(ctrl->IsOpen() && ctrl->IsVisible() && ctrl->IsEnabled() && ctrl->HotKey(key))
{
if(Config::user_log && s_hotkey) {
if(Ini::user_log && s_hotkey) {
USRLOG(" HOT-> " << UPP::Name(ctrl));
s_hotkey = false;
}

View file

@ -30,7 +30,7 @@ dword GetMouseFlags() {
void Ctrl::LogMouseEvent(const char *f, const Ctrl *ctrl, int event, Point p, int zdelta, dword keyflags)
{
if(!Config::user_log)
if(!Ini::user_log)
return;
String txt = f;
txt += (event & BUTTON) == RIGHT ? "RIGHT" : (event & BUTTON) == MIDDLE ? "MIDDLE" : "LEFT";