start working on 0.7.x branch

- added FileLog which stores content to the file log
- now Log is only a wrapper - it puts messages to the local buffer and when logsave is used then the buffer is put to FileLog
- new base classes:
  WinixBase (Log, Config*, Synchro*)
  WinixModel : public WinixBase (morm::ModelConnector*, Plugin*)
  WinixSystem : public WinixModel (System*)
  WinixRequest : public WinixSystem (SLog, Cur*)
- singletons: log, slog, plugin are depracated - now references to them are in base classses (WinixBase, WinixModel)
- DbBase,  DbConn and Db are depracated - now we are using Morm project (in WinixModel there is a model_connector pointer)
  each thread will have its own ModelConnector





git-svn-id: svn://ttmath.org/publicrep/winix/branches/0.7.x@1146 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2018-11-21 11:03:53 +00:00
parent a7c47140ae
commit a2ffc1e81c
121 changed files with 7832 additions and 6662 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
@@ -43,6 +43,7 @@
#include "textstream.h"
#include "logmanipulators.h"
#include "textstream/textstream.h"
#include "filelog.h"
namespace Winix
@@ -50,10 +51,6 @@ namespace Winix
class TimeZones;
class Log
{
public:
@@ -61,8 +58,14 @@ public:
Log();
~Log();
void SetTimeZones(TimeZones * ptime_zones);
void Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests);
void SetLogBuffer(TextStream<std::wstring> * buffer);
void SetFileLog(FileLog * file_log);
FileLog * GetFileLog();
void SetDependency(Log * log);
void Init(int log_level, bool save_each_line, int max_requests);
Log & operator<<(const void * s);
Log & operator<<(const char * s);
@@ -81,7 +84,7 @@ public:
Log & operator<<(LogManipulators m);
Log & operator<<(const PT::Date & date);
void PrintDate(const PT::Date & date, size_t time_zone_id);
void PrintDate(const PT::Date & date);
template<typename char_type, size_t stack_size, size_t heap_block_size>
Log & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
@@ -101,13 +104,11 @@ public:
int LogLevel();
private:
// time zones for printing the time in the log file
TimeZones * time_zones;
// buffer for the log
TextStream<std::wstring> buffer;
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;
@@ -122,19 +123,9 @@ private:
// how many request to save at once
int max_requests;
// file log
std::string log_file;
std::ofstream file;
// logging to stdout
bool log_stdout;
// how many lines there are in the buffer
int lines;
// is the config file already open
bool log_file_open;
// how many lines can be in the config buffer
// default: 5000
int max_lines;
@@ -142,7 +133,8 @@ private:
// whether to save each line (for debug)
bool save_each_line;
void OpenFile();
FileLog * file_log;
char GetHEXdigit(unsigned char c);
void ToHEX(char * buf, unsigned char c);
@@ -155,14 +147,14 @@ 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 )
if( current_level <= log_level && buffer )
{
for(size_t i=0 ; i<min_size ; ++i)
{
if( value[i] < 32 )
buffer << '.';
(*buffer) << '.';
else
buffer << value[i];
(*buffer) << value[i];
}
}
}
@@ -172,28 +164,17 @@ 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 << buf;
if( current_level <= log_level && buffer )
(*buffer) << buf;
return *this;
}
extern Log log;
extern Log nlog;
} // namespace Winix
// for convenience, we have to use only #include "log.h" in the winix
#include "slog.h"
#endif