some work on dependency injection

git-svn-id: svn://ttmath.org/publicrep/winix/branches/0.7.x@1147 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2018-11-21 17:51:15 +00:00
parent a2ffc1e81c
commit 89d303f375
64 changed files with 1734 additions and 1161 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,7 @@
#include "core/version.h"
#include "utf8/utf8.h"
#include "core/filelog.h"
#include "core/log.h"
@@ -98,7 +99,7 @@ void CloseDescriptors()
}
void LogInfo(LogManipulators log_level, const char * msg, bool put_version, const char * msg2)
void LogInfo(Log & log, LogManipulators log_level, const char * msg, bool put_version, const char * msg2)
{
log << log_level;
log.PrintDate(PT::Date(std::time(0)));
@@ -115,7 +116,7 @@ void LogInfo(LogManipulators log_level, const char * msg, bool put_version, cons
}
void SavePidFile()
void SavePidFile(Log & log)
{
if( !app.config.pid_file.empty() )
{
@@ -158,6 +159,10 @@ using Winix::app;
std::srand(std::time(0));
Winix::TextStream<std::wstring> log_buffer;
Winix::Log log; // log only for main() function
log.SetLogBuffer(&log_buffer);
if( argv != 2 )
{
Winix::print_syntax();
@@ -186,11 +191,10 @@ using Winix::app;
app.InitFileLog();
log.SetFileLog(&app.file_log);
log.Init(app.config.log_level, app.config.log_save_each_line, app.config.log_request);
Winix::log.SetFileLog(&app.file_log); // IMPROVE ME the singleton will be removed
Winix::log.Init(app.config.log_level, app.config.log_save_each_line, app.config.log_request);
Winix::LogInfo(Winix::log3, "booting Winix", true, "");
Winix::LogInfo(log, Winix::log3, "booting Winix", true, "");
if( !app.InitFCGI() )
return 5;
@@ -199,8 +203,7 @@ using Winix::app;
return 3;
app.LogUserGroups();
Winix::log << Winix::log3 << "base_url: " << app.config.base_url << Winix::logend;
Winix::SavePidFile();
Winix::SavePidFile(log);
// load plugins before loading sessions - session_manager.LoadSessions()
// because some of the plugins can init its own sessions dates
@@ -218,8 +221,8 @@ using Winix::app;
// saving all starting logs
app.Lock();
Winix::LogInfo(Winix::log1, "Winix", true, "started");
Winix::log << Winix::logsave;
Winix::LogInfo(log, Winix::log1, "Winix", true, "started");
log << Winix::logsave;
app.Unlock();
// main loop
@@ -227,8 +230,9 @@ using Winix::app;
app.Close();
Winix::LogInfo(Winix::log1, "Winix", true, "stopped");
Winix::LogInfo(log, Winix::log1, "Winix", true, "stopped");
Winix::RemovePidFile();
log << Winix::logsave;
return 0;
}