some work in the new api:
- log_level and save_each_line moved from Log to FileLog - other fixes in loggers - DirContainer from Dirs and LoadAvg had no dependencies set git-svn-id: svn://ttmath.org/publicrep/winix/branches/0.7.x@1148 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
1 parent
89d303f375
commit
491dd27ebf
18 files changed
+116
-81
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
winix.src.files = ./core/synchro.h ./core/sessioncontainer.h ./core/cookieparser.h ./core/misc.cpp ./core/item.cpp ./core/error.h ./core/timezone.h ./core/compress.h ./core/crypt.cpp ./core/dirs.cpp ./core/slog.cpp ./core/config.cpp ./core/lastcontainer.cpp ./core/users.h ./core/httpsimpleparser.cpp ./core/threadmanager.h ./core/postparser.h ./core/pluginmsg.h ./core/acceptbaseparser.h ./core/loadavg.cpp ./core/job.h ./core/mountparser.cpp ./core/timezones.h ./core/sessionmanager.h ./core/groups.h ./core/system.cpp ./core/rebus.h ./core/synchro.cpp ./core/lock.cpp ./core/acceptencodingparser.h ./core/version.h ./core/compress.cpp ./core/ipbancontainer.cpp ./core/request.h ./core/plugindata.h ./core/plugin.cpp ./core/sessionparser.cpp ./core/bbcodeparser.h ./core/users.cpp ./core/mount.cpp ./core/item.h ./core/slog.h ./core/threadmanager.cpp ./core/acceptbaseparser.cpp ./core/lastcontainer.h ./core/httpsimpleparser.h ./core/timezones.cpp ./core/groups.cpp ./core/requesttypes.h ./core/system.h ./core/bbcodeparser.cpp ./core/lock.h ./core/ipbancontainer.h ./core/group.h ./core/plugin.h ./core/run.cpp ./core/textstream.h ./core/sessionparser.h ./core/basethread.h ./core/mount.h ./core/htmlfilter.cpp ./core/user.cpp ./core/app.cpp ./core/image.cpp ./core/ugcontainer.h ./core/postmultiparser.h ./core/logmanipulators.h ./core/sessioncontainer.cpp ./core/dircontainer.h ./core/log.h ./core/session.h ./core/timezone.cpp ./core/mounts.h ./core/ipban.h ./core/cur.h ./core/misc.h ./core/dirs.h ./core/crypt.h ./core/run.h ./core/config.h ./core/job.cpp ./core/postmultiparser.cpp ./core/sessionmanager.cpp ./core/htmlfilter.h ./core/rebus.cpp ./core/dircontainer.cpp ./core/log.cpp ./core/user.h ./core/loadavg.h ./core/session.cpp ./core/mountparser.h ./core/mounts.cpp ./core/image.h ./core/plugindata.cpp ./core/request.cpp ./core/app.h ./core/basethread.cpp ./core/sessionidmanager.h ./core/winix_const.h ./core/sessionidmanager.cpp ./core/winixbase.h ./core/winixmodel.h ./core/filelog.h ./core/filelog.cpp ./core/winixbase.cpp ./core/winixmodel.cpp ./core/winixsystem.h ./core/winixsystem.cpp ./core/winixrequest.h ./core/winixrequest.cpp ./db/dbconn.cpp ./db/db.cpp ./db/dbbase.h ./db/dbitemcolumns.cpp ./db/dbtextstream.cpp ./db/dbconn.h ./db/db.h ./db/dbitemcolumns.h ./db/dbitemquery.cpp ./db/dbtextstream.h ./db/dbitemquery.h ./db/dbbase.cpp ./functions/upload.cpp ./functions/priv.h ./functions/env.cpp ./functions/default.h ./functions/node.h ./functions/specialdefault.h ./functions/timezone.cpp ./functions/pw.h ./functions/adduser.h ./functions/chmod.h ./functions/imgcrop.cpp ./functions/vim.h ./functions/account.h ./functions/mount.cpp ./functions/uptime.cpp ./functions/ckeditor.cpp ./functions/mkdir.cpp ./functions/reload.cpp ./functions/functionparser.h ./functions/logout.cpp ./functions/rmuser.cpp ./functions/rm.cpp ./functions/chown.h ./functions/nicedit.h ./functions/mv.h ./functions/node.cpp ./functions/specialdefault.cpp ./functions/adduser.cpp ./functions/upload.h ./functions/vim.cpp ./functions/env.h ./functions/timezone.h ./functions/who.h ./functions/cp.cpp ./functions/run.cpp ./functions/locale.h ./functions/imgcrop.h ./functions/passwd.h ./functions/mount.h ./functions/privchanger.cpp ./functions/functions.cpp ./functions/last.h ./functions/ckeditor.h ./functions/mkdir.h ./functions/reload.h ./functions/cat.h ./functions/download.h ./functions/ln.h ./functions/nicedit.cpp ./functions/functionbase.cpp ./functions/man.h ./functions/rm.h ./functions/meta.cpp ./functions/emacs.cpp ./functions/sort.h ./functions/who.cpp ./functions/ipban.h ./functions/locale.cpp ./functions/passwd.cpp ./functions/last.cpp ./functions/subject.h ./functions/download.cpp ./functions/cp.h ./functions/cat.cpp ./functions/login.cpp ./functions/tinymce.cpp ./functions/ln.cpp ./functions/run.h ./functions/uname.h ./functions/man.cpp ./functions/functions.h ./functions/privchanger.h ./functions/ls.cpp ./functions/template.h ./functions/stat.h ./functions/priv.cpp ./functions/default.cpp ./functions/functionbase.h ./functions/pw.cpp ./functions/sort.cpp ./functions/ipban.cpp ./functions/chmod.cpp ./functions/meta.h ./functions/account.cpp ./functions/emacs.h ./functions/subject.cpp ./functions/functionparser.cpp ./functions/uname.cpp ./functions/uptime.h ./functions/template.cpp ./functions/stat.cpp ./functions/tinymce.h ./functions/login.h ./functions/chown.cpp ./functions/logout.h ./functions/mv.cpp ./functions/rmuser.h ./functions/ls.h ./main/main.cpp ./notify/notifypool.h ./notify/templatesnotify.cpp ./notify/notify.cpp ./notify/templatesnotify.h ./notify/notify.h ./notify/notifythread.cpp ./notify/notifypool.cpp ./notify/notifythread.h ./plugins/group/init.cpp ./plugins/group/groups.h ./plugins/group/groupinfo
Line truncated
|
||||
winix.src.files = ./core/synchro.h ./core/sessioncontainer.h ./core/cookieparser.h ./core/misc.cpp ./core/item.cpp ./core/error.h ./core/timezone.h ./core/compress.h ./core/crypt.cpp ./core/dirs.cpp ./core/slog.cpp ./core/config.cpp ./core/lastcontainer.cpp ./core/users.h ./core/httpsimpleparser.cpp ./core/threadmanager.h ./core/postparser.h ./core/pluginmsg.h ./core/acceptbaseparser.h ./core/loadavg.cpp ./core/job.h ./core/mountparser.cpp ./core/timezones.h ./core/sessionmanager.h ./core/groups.h ./core/system.cpp ./core/rebus.h ./core/synchro.cpp ./core/lock.cpp ./core/acceptencodingparser.h ./core/version.h ./core/compress.cpp ./core/ipbancontainer.cpp ./core/request.h ./core/plugindata.h ./core/plugin.cpp ./core/sessionparser.cpp ./core/bbcodeparser.h ./core/users.cpp ./core/mount.cpp ./core/item.h ./core/slog.h ./core/threadmanager.cpp ./core/acceptbaseparser.cpp ./core/lastcontainer.h ./core/httpsimpleparser.h ./core/timezones.cpp ./core/groups.cpp ./core/requesttypes.h ./core/system.h ./core/bbcodeparser.cpp ./core/lock.h ./core/ipbancontainer.h ./core/group.h ./core/plugin.h ./core/run.cpp ./core/textstream.h ./core/sessionparser.h ./core/basethread.h ./core/mount.h ./core/htmlfilter.cpp ./core/user.cpp ./core/app.cpp ./core/image.cpp ./core/ugcontainer.h ./core/postmultiparser.h ./core/logmanipulators.h ./core/sessioncontainer.cpp ./core/dircontainer.h ./core/log.h ./core/session.h ./core/timezone.cpp ./core/mounts.h ./core/ipban.h ./core/cur.h ./core/misc.h ./core/dirs.h ./core/crypt.h ./core/run.h ./core/config.h ./core/job.cpp ./core/postmultiparser.cpp ./core/sessionmanager.cpp ./core/htmlfilter.h ./core/rebus.cpp ./core/dircontainer.cpp ./core/log.cpp ./core/user.h ./core/loadavg.h ./core/session.cpp ./core/mountparser.h ./core/mounts.cpp ./core/image.h ./core/plugindata.cpp ./core/request.cpp ./core/app.h ./core/basethread.cpp ./core/sessionidmanager.h ./core/winix_const.h ./core/sessionidmanager.cpp ./core/filelog.cpp ./core/filelog.h ./core/winixbase.cpp ./core/winixbase.h ./core/winixmodel.cpp ./core/winixmodel.h ./core/winixrequest.cpp ./core/winixrequest.h ./core/winixsystem.cpp ./core/winixsystem.h ./db/dbconn.cpp ./db/db.cpp ./db/dbbase.h ./db/dbitemcolumns.cpp ./db/dbtextstream.cpp ./db/dbconn.h ./db/db.h ./db/dbitemcolumns.h ./db/dbitemquery.cpp ./db/dbtextstream.h ./db/dbitemquery.h ./db/dbbase.cpp ./functions/upload.cpp ./functions/priv.h ./functions/env.cpp ./functions/default.h ./functions/node.h ./functions/specialdefault.h ./functions/timezone.cpp ./functions/pw.h ./functions/adduser.h ./functions/chmod.h ./functions/imgcrop.cpp ./functions/vim.h ./functions/account.h ./functions/mount.cpp ./functions/uptime.cpp ./functions/ckeditor.cpp ./functions/mkdir.cpp ./functions/reload.cpp ./functions/functionparser.h ./functions/logout.cpp ./functions/rmuser.cpp ./functions/rm.cpp ./functions/chown.h ./functions/nicedit.h ./functions/mv.h ./functions/node.cpp ./functions/specialdefault.cpp ./functions/adduser.cpp ./functions/upload.h ./functions/vim.cpp ./functions/env.h ./functions/timezone.h ./functions/who.h ./functions/cp.cpp ./functions/run.cpp ./functions/locale.h ./functions/imgcrop.h ./functions/passwd.h ./functions/mount.h ./functions/privchanger.cpp ./functions/functions.cpp ./functions/last.h ./functions/ckeditor.h ./functions/mkdir.h ./functions/reload.h ./functions/cat.h ./functions/download.h ./functions/ln.h ./functions/nicedit.cpp ./functions/functionbase.cpp ./functions/man.h ./functions/rm.h ./functions/meta.cpp ./functions/emacs.cpp ./functions/sort.h ./functions/who.cpp ./functions/ipban.h ./functions/locale.cpp ./functions/passwd.cpp ./functions/last.cpp ./functions/subject.h ./functions/download.cpp ./functions/cp.h ./functions/cat.cpp ./functions/login.cpp ./functions/tinymce.cpp ./functions/ln.cpp ./functions/run.h ./functions/uname.h ./functions/man.cpp ./functions/functions.h ./functions/privchanger.h ./functions/ls.cpp ./functions/template.h ./functions/stat.h ./functions/priv.cpp ./functions/default.cpp ./functions/functionbase.h ./functions/pw.cpp ./functions/sort.cpp ./functions/ipban.cpp ./functions/chmod.cpp ./functions/meta.h ./functions/account.cpp ./functions/emacs.h ./functions/subject.cpp ./functions/functionparser.cpp ./functions/uname.cpp ./functions/uptime.h ./functions/template.cpp ./functions/stat.cpp ./functions/tinymce.h ./functions/login.h ./functions/chown.cpp ./functions/logout.h ./functions/mv.cpp ./functions/rmuser.h ./functions/ls.h ./main/main.cpp ./notify/notifypool.h ./notify/templatesnotify.cpp ./notify/notify.cpp ./notify/templatesnotify.h ./notify/notify.h ./notify/notifythread.cpp ./notify/notifypool.cpp ./notify/notifythread.h ./plugins/group/init.cpp ./plugins/group/groups.h ./plugins/group/groupinfo
Line truncated
|
||||
+14
-8
@@ -65,9 +65,11 @@ App::App()
|
||||
last_sessions_save = std::time(0);
|
||||
fcgi_socket = -1;
|
||||
|
||||
file_log.set_synchro(&synchro);
|
||||
file_log.set_time_zones(&system.time_zones);
|
||||
|
||||
log.SetLogBuffer(&log_buffer);
|
||||
log.SetFileLog(&file_log);
|
||||
log.Init(config.log_level, config.log_save_each_line, config.log_request);
|
||||
|
||||
// objects dependency for main thread
|
||||
winix_base.set_config(&config);
|
||||
@@ -90,6 +92,7 @@ App::App()
|
||||
|
||||
|
||||
config.SetFileLog(&file_log);
|
||||
config.SetLogBuffer(&log_buffer);
|
||||
|
||||
|
||||
// temporary there is only one request
|
||||
@@ -159,17 +162,20 @@ App::App()
|
||||
|
||||
|
||||
|
||||
void App::InitFileLog()
|
||||
void App::InitLoggers()
|
||||
{
|
||||
file_log.set_synchro(&synchro);
|
||||
file_log.set_time_zones(&system.time_zones);
|
||||
file_log.init(config.log_file, config.log_stdout, config.log_time_zone_id);
|
||||
|
||||
log.SetFileLog(&file_log);
|
||||
log.Init(config.log_level, config.log_save_each_line, config.log_request);
|
||||
file_log.init(config.log_file, config.log_stdout, config.log_level, config.log_save_each_line, config.log_time_zone_id);
|
||||
log.Init(config.log_request);
|
||||
}
|
||||
|
||||
|
||||
Log & App::GetMainLog()
|
||||
{
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::InitPlugins()
|
||||
{
|
||||
plugin.LoadPlugins(config.plugins_dir, config.plugin_file);
|
||||
|
||||
+5
-4
@@ -75,7 +75,8 @@ public:
|
||||
|
||||
bool InitFCGI();
|
||||
bool DropPrivileges();
|
||||
void InitFileLog();
|
||||
void InitLoggers();
|
||||
Log & GetMainLog();
|
||||
void InitPlugins();
|
||||
bool Init();
|
||||
void Start();
|
||||
@@ -131,9 +132,6 @@ public:
|
||||
|
||||
|
||||
|
||||
FileLog file_log;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -190,6 +188,9 @@ private:
|
||||
// logger only for App object
|
||||
Log log;
|
||||
|
||||
// file logger, one object for every Log objects
|
||||
FileLog file_log;
|
||||
|
||||
bool InitFCGI(char * sock, char * sock_user, char * sock_group);
|
||||
bool InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group);
|
||||
bool DropPrivileges(char * user, char * group);
|
||||
|
||||
@@ -54,7 +54,13 @@ void Config::SetFileLog(FileLog * file_log)
|
||||
log.SetFileLog(file_log);
|
||||
|
||||
// the config is not read yet so we put some constants here
|
||||
log.Init(3, false, 1);
|
||||
log.Init(1);
|
||||
}
|
||||
|
||||
|
||||
void Config::SetLogBuffer(TextStream<std::wstring> * log_buffer)
|
||||
{
|
||||
log.SetLogBuffer(log_buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -819,7 +819,10 @@ public:
|
||||
// raw access to the config
|
||||
PT::Space space;
|
||||
|
||||
|
||||
void SetFileLog(FileLog * file_log);
|
||||
void SetLogBuffer(TextStream<std::wstring> * log_buffer);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -60,6 +60,13 @@ void Dirs::SetNotify(Notify * pnotify)
|
||||
}
|
||||
|
||||
|
||||
void Dirs::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixModel::set_dependency(winix_model);
|
||||
dir_tab.set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
void Dirs::Clear()
|
||||
{
|
||||
dir_tab.Clear();
|
||||
|
||||
@@ -69,6 +69,8 @@ public:
|
||||
void SetDb(Db * pdb);
|
||||
void SetNotify(Notify * pnotify);
|
||||
|
||||
void set_dependency(WinixModel * winix_model);
|
||||
|
||||
// these methods return false if there is no such a dir
|
||||
bool IsDir(long dir_id);
|
||||
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_tab); // !! zamienic na GetChilds()
|
||||
|
||||
+17
-2
@@ -66,23 +66,38 @@ void FileLog::set_synchro(Synchro * synchro)
|
||||
}
|
||||
|
||||
|
||||
void FileLog::init(const std::wstring & log_file, bool log_stdout, size_t log_time_zone_id)
|
||||
void FileLog::init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id)
|
||||
{
|
||||
this->log_stdout = log_stdout;
|
||||
this->log_time_zone_id = log_time_zone_id;
|
||||
this->log_level = log_level;
|
||||
this->save_each_line = save_each_line;
|
||||
PT::WideToUTF8(log_file, this->log_file);
|
||||
// don't open the file here
|
||||
// because it would be created with the root as an owner
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FileLog::set_time_zones(TimeZones * time_zones)
|
||||
{
|
||||
this->time_zones = time_zones;
|
||||
}
|
||||
|
||||
|
||||
int FileLog::get_log_level()
|
||||
{
|
||||
return log_level;
|
||||
}
|
||||
|
||||
|
||||
bool FileLog::should_save_each_line()
|
||||
{
|
||||
return save_each_line;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
PT::Date FileLog::get_local_date(const PT::Date & date)
|
||||
{
|
||||
if( time_zones )
|
||||
|
||||
+10
-1
@@ -58,12 +58,14 @@ public:
|
||||
|
||||
void set_synchro(Synchro * synchro);
|
||||
|
||||
void init(const std::wstring & log_file, bool log_stdout, size_t log_time_zone_id);
|
||||
void init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id);
|
||||
void save_log(TextStream<std::wstring> * buffer);
|
||||
|
||||
void set_time_zones(TimeZones * time_zones);
|
||||
PT::Date get_local_date(const PT::Date & date);
|
||||
|
||||
int get_log_level();
|
||||
bool should_save_each_line();
|
||||
|
||||
private:
|
||||
|
||||
@@ -83,6 +85,13 @@ private:
|
||||
|
||||
Synchro * synchro;
|
||||
|
||||
// log lovel from the config file
|
||||
int log_level;
|
||||
|
||||
// whether to save each line (for debug)
|
||||
bool save_each_line;
|
||||
|
||||
|
||||
void open_file();
|
||||
};
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Winix
|
||||
|
||||
|
||||
|
||||
class LoadAvg : WinixBase
|
||||
class LoadAvg : public WinixBase
|
||||
{
|
||||
public:
|
||||
LoadAvg();
|
||||
|
||||
+20
-30
@@ -46,14 +46,12 @@ namespace Winix
|
||||
|
||||
Log::Log()
|
||||
{
|
||||
log_level = 1;
|
||||
current_level = 100; // nothing to log (call Init() first)
|
||||
request = 0;
|
||||
max_requests = 1;
|
||||
lines = 0;
|
||||
max_lines = 5000;
|
||||
file_log = nullptr;
|
||||
save_each_line = false;
|
||||
buffer = nullptr;
|
||||
}
|
||||
|
||||
@@ -89,17 +87,9 @@ void Log::SetDependency(Log * log)
|
||||
}
|
||||
|
||||
|
||||
int Log::LogLevel()
|
||||
|
||||
void Log::Init(int max_requests)
|
||||
{
|
||||
return log_level;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::Init(int log_level, bool save_each_line, int max_requests)
|
||||
{
|
||||
this->log_level = log_level;
|
||||
this->save_each_line = save_each_line;
|
||||
this->max_requests = max_requests;
|
||||
}
|
||||
|
||||
@@ -121,7 +111,7 @@ void Log::PrintDate(const PT::Date & date)
|
||||
|
||||
Log & Log::operator<<(const void * s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -133,7 +123,7 @@ Log & Log::operator<<(const void * s)
|
||||
|
||||
Log & Log::operator<<(const char * s)
|
||||
{
|
||||
if( current_level <= log_level && buffer && s )
|
||||
if( current_level <= file_log->get_log_level() && buffer && s )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -145,7 +135,7 @@ return *this;
|
||||
|
||||
Log & Log::operator<<(const std::string & s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -157,7 +147,7 @@ Log & Log::operator<<(const std::string & s)
|
||||
|
||||
Log & Log::operator<<(const std::string * s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << *s;
|
||||
}
|
||||
@@ -172,7 +162,7 @@ Log & Log::operator<<(const std::string * s)
|
||||
|
||||
Log & Log::operator<<(const wchar_t * s)
|
||||
{
|
||||
if( current_level <= log_level && buffer && s )
|
||||
if( current_level <= file_log->get_log_level() && buffer && s )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -184,7 +174,7 @@ return *this;
|
||||
|
||||
Log & Log::operator<<(const std::wstring & s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -196,7 +186,7 @@ Log & Log::operator<<(const std::wstring & s)
|
||||
|
||||
Log & Log::operator<<(const std::wstring * s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << *s;
|
||||
}
|
||||
@@ -210,7 +200,7 @@ Log & Log::operator<<(const std::wstring * s)
|
||||
|
||||
Log & Log::operator<<(int s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -222,7 +212,7 @@ Log & Log::operator<<(int s)
|
||||
|
||||
Log & Log::operator<<(long s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -235,7 +225,7 @@ Log & Log::operator<<(long s)
|
||||
|
||||
Log & Log::operator<<(char s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -246,7 +236,7 @@ Log & Log::operator<<(char s)
|
||||
|
||||
Log & Log::operator<<(wchar_t s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -257,7 +247,7 @@ Log & Log::operator<<(wchar_t s)
|
||||
|
||||
Log & Log::operator<<(size_t s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -269,7 +259,7 @@ Log & Log::operator<<(size_t s)
|
||||
|
||||
Log & Log::operator<<(double s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -281,7 +271,7 @@ Log & Log::operator<<(double s)
|
||||
|
||||
Log & Log::operator<<(const PT::Space & s)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << s;
|
||||
}
|
||||
@@ -293,7 +283,7 @@ return *this;
|
||||
|
||||
Log & Log::operator<<(const PT::Date & date)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << date;
|
||||
}
|
||||
@@ -308,12 +298,12 @@ Log & Log::operator<<(LogManipulators m)
|
||||
switch(m)
|
||||
{
|
||||
case logend:
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
(*buffer) << '\n';
|
||||
lines += 1;
|
||||
|
||||
if( save_each_line )
|
||||
if( file_log->should_save_each_line() )
|
||||
SaveLogAndClear();
|
||||
}
|
||||
break;
|
||||
@@ -455,7 +445,7 @@ void Log::SaveLogAndClear()
|
||||
|
||||
void Log::SaveLog()
|
||||
{
|
||||
if( file_log && buffer )
|
||||
if( buffer )
|
||||
{
|
||||
file_log->save_log(buffer);
|
||||
}
|
||||
|
||||
+5
-9
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
void SetDependency(Log * log);
|
||||
|
||||
void Init(int log_level, bool save_each_line, int max_requests);
|
||||
void Init(int max_requests);
|
||||
|
||||
Log & operator<<(const void * s);
|
||||
Log & operator<<(const char * s);
|
||||
@@ -101,7 +101,6 @@ public:
|
||||
void SaveLog();
|
||||
void SaveLogAndClear();
|
||||
|
||||
int LogLevel();
|
||||
|
||||
|
||||
|
||||
@@ -110,9 +109,6 @@ private:
|
||||
// buffer for the log
|
||||
TextStream<std::wstring> * buffer; // IMPROVE ME this buffer should be a common buffer for all objects for a one thread
|
||||
|
||||
// log lovel from the config file
|
||||
int log_level;
|
||||
|
||||
// current level set by a modifier (e.g. log << log3)
|
||||
int current_level;
|
||||
|
||||
@@ -123,6 +119,8 @@ private:
|
||||
// how many request to save at once
|
||||
int max_requests;
|
||||
|
||||
|
||||
// IMPROVE ME now we don't know how many lines there are in the buffer as the buffer can be used by other Logs
|
||||
// how many lines there are in the buffer
|
||||
int lines;
|
||||
|
||||
@@ -130,8 +128,6 @@ private:
|
||||
// default: 5000
|
||||
int max_lines;
|
||||
|
||||
// whether to save each line (for debug)
|
||||
bool save_each_line;
|
||||
|
||||
FileLog * file_log;
|
||||
|
||||
@@ -147,7 +143,7 @@ void Log::LogString(const StringType & value, size_t max_size)
|
||||
{
|
||||
size_t min_size = value.size() < max_size ? value.size() : max_size;
|
||||
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
{
|
||||
for(size_t i=0 ; i<min_size ; ++i)
|
||||
{
|
||||
@@ -164,7 +160,7 @@ size_t min_size = value.size() < max_size ? value.size() : max_size;
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
Log & Log::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
|
||||
{
|
||||
if( current_level <= log_level && buffer )
|
||||
if( current_level <= file_log->get_log_level() && buffer )
|
||||
(*buffer) << buf;
|
||||
|
||||
return *this;
|
||||
|
||||
@@ -197,7 +197,7 @@ bool Plugin::SetDependency(PluginInfo & info)
|
||||
info.plugin = this;
|
||||
|
||||
info.log.SetDependency(&log);
|
||||
log.Init(config->log_level, config->log_save_each_line, config->log_request);
|
||||
log.Init(config->log_request);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
+15
-9
@@ -83,9 +83,20 @@ void System::SetSessionManager(SessionManager * sm)
|
||||
|
||||
void System::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixModel::set_dependency(winix_model);
|
||||
|
||||
dirs.set_dependency(this);
|
||||
mounts.set_dependency(this);
|
||||
users.set_dependency(this);
|
||||
groups.set_dependency(this);
|
||||
rebus.set_dependency(this);
|
||||
load_avg.set_dependency(this);
|
||||
notify.set_dependency(this);
|
||||
image.set_dependency(this);
|
||||
crypt.set_dependency(this);
|
||||
thread_manager.set_dependency(this);
|
||||
job.set_dependency(winix_model);
|
||||
time_zones.set_dependency(winix_model);
|
||||
WinixModel::set_dependency(winix_model);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,16 +126,13 @@ void System::ReadTimeZones()
|
||||
void System::Init()
|
||||
{
|
||||
//thread_manager.SetSynchro(synchro);
|
||||
thread_manager.set_dependency(this);
|
||||
thread_manager.Init();
|
||||
|
||||
dirs.set_dependency(this);
|
||||
dirs.SetDb(db);
|
||||
dirs.SetCur(cur); // only one method is using cur, can be passed as a parameter to the method
|
||||
dirs.SetNotify(¬ify);
|
||||
dirs.ReadDirs();
|
||||
|
||||
mounts.set_dependency(this);
|
||||
mounts.SkipStaticDirs(config->dont_use_static_dirs);
|
||||
mounts.SetDirs(&dirs);
|
||||
mounts.SetDb(db);
|
||||
@@ -132,19 +140,16 @@ void System::Init()
|
||||
mounts.CreateMounts();
|
||||
mounts.ReadMounts();
|
||||
|
||||
users.set_dependency(this);
|
||||
users.SetCur(cur);
|
||||
users.SetSessionManager(session_manager);
|
||||
users.ReadUsers(db);
|
||||
|
||||
groups.set_dependency(this);
|
||||
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
|
||||
|
||||
rebus.set_dependency(this);
|
||||
rebus.SetCur(cur);
|
||||
rebus.Init();
|
||||
|
||||
notify.set_dependency(this);
|
||||
|
||||
notify.SetCur(cur);
|
||||
//notify.SetConfig(config);
|
||||
notify.SetUsers(&users);
|
||||
@@ -157,7 +162,8 @@ void System::Init()
|
||||
image.SetSystem(this);
|
||||
thread_manager.Add(&image, L"image");
|
||||
|
||||
crypt.set_dependency(this);
|
||||
|
||||
|
||||
|
||||
// SetSynchro will be called by ThreadManager itself
|
||||
// job.ReadFromFile();
|
||||
|
||||
@@ -79,7 +79,7 @@ void WinixBase::set_dependency(WinixBase * winix_base)
|
||||
{
|
||||
config = winix_base->config;
|
||||
synchro = winix_base->synchro;
|
||||
log.SetFileLog(winix_base->log.GetFileLog());
|
||||
log.SetDependency(&winix_base->log);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ void WinixModel::set_dependency(WinixModel * winix_model)
|
||||
{
|
||||
WinixBase::set_dependency(winix_model);
|
||||
model_connector = winix_model->model_connector;
|
||||
plugin = winix_model->plugin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-11
@@ -43,8 +43,7 @@
|
||||
#include "core/app.h"
|
||||
#include "core/version.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "core/filelog.h"
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -159,10 +158,6 @@ 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();
|
||||
@@ -180,6 +175,9 @@ using Winix::app;
|
||||
if( !app.config.ReadConfig(true, false) ) /* errors to stdout, stdout in not closed */
|
||||
return 2;
|
||||
|
||||
Winix::Log & log = app.GetMainLog();
|
||||
app.InitLoggers();
|
||||
|
||||
if( app.stdout_is_closed || app.config.demonize )
|
||||
app.config.log_stdout = false;
|
||||
|
||||
@@ -189,11 +187,6 @@ using Winix::app;
|
||||
if( app.config.demonize && !app.Demonize() )
|
||||
return 4;
|
||||
|
||||
|
||||
app.InitFileLog();
|
||||
log.SetFileLog(&app.file_log);
|
||||
log.Init(app.config.log_level, app.config.log_save_each_line, app.config.log_request);
|
||||
|
||||
Winix::LogInfo(log, Winix::log3, "booting Winix", true, "");
|
||||
|
||||
if( !app.InitFCGI() )
|
||||
|
||||
@@ -1184,8 +1184,8 @@ void Templates::set_dependency(WinixRequest * winix_request)
|
||||
TemplatesFunctions::locale_filter.set_dependency(winix_request);
|
||||
TemplatesFunctions::html_filter.set_dependency(winix_request);
|
||||
|
||||
log.SetDependency(&this->log);
|
||||
log.Init(config->log_level, config->log_save_each_line, config->log_request);
|
||||
TemplatesFunctions::log.SetDependency(&this->log);
|
||||
TemplatesFunctions::log.Init(config->log_request);
|
||||
|
||||
plugin = winix_request->get_plugin();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user