25 #include <boost/filesystem/path.hpp> 26 #include <boost/filesystem/operations.hpp> 33 #if defined(_SYSTEM_POSIX_) && !defined(__ANDROID__) 53 m_delete_old_files(false),
54 m_delete_older_than_days(0)
55 #if defined(_IC_BUILDER_ZLIB_)
56 , m_zipped_log_file(NULL)
70 #if defined(_IC_BUILDER_ZLIB_) 71 m_online_zip = icl_core::config::getDefault<bool>(config_prefix +
"/Zip",
false);
74 m_flush = icl_core::config::getDefault<bool>(config_prefix +
"/Flush",
true);
76 if (icl_core::config::get<icl_core::String>(config_prefix +
"/FileName",
m_filename))
82 boost::filesystem::path log_file_path(
m_filename);
83 if (boost::filesystem::exists(log_file_path))
85 if (boost::filesystem::is_directory(log_file_path))
87 std::cerr <<
"The filename specified for log output stream " 88 << config_prefix <<
" is a directory." <<
std::endl;
101 std::cerr <<
"No filename specified for file log output stream " << config_prefix <<
std::endl;
114 #if defined(_IC_BUILDER_ZLIB_)
115 , m_online_zip(false),
116 m_zipped_log_file(NULL)
139 #ifdef _IC_BUILDER_ZLIB_ 142 gzwrite(m_zipped_log_file, log_line.c_str(),
static_cast<unsigned int>(log_line.length()));
159 #ifdef _IC_BUILDER_ZLIB_ 162 return m_zipped_log_file != NULL;
173 #ifdef _IC_BUILDER_ZLIB_ 176 gzflush(m_zipped_log_file, Z_SYNC_FLUSH);
187 #ifdef _IC_BUILDER_ZLIB_ 190 if (m_zipped_log_file != NULL)
192 gzclose(m_zipped_log_file);
193 m_zipped_log_file = NULL;
208 #if defined(_IC_BUILDER_ZLIB_) 211 m_zipped_log_file = gzopen(
m_filename.c_str(),
"a+b");
212 if (m_zipped_log_file == NULL)
218 const char *
buffer =
"\n\n-------------FILE (RE-)OPENED------------------\n";
219 gzwrite(m_zipped_log_file, buffer, static_cast<unsigned int>(strlen(buffer)));
229 m_log_file <<
"\n\n-------------FILE (RE-)OPENED------------------\n";
252 #ifdef _IC_BUILDER_ZLIB_ 255 icl_core::os::zipFile(
m_filename.c_str(), time_str);
267 #if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 268 boost::filesystem::path log_file_path = boost::filesystem::path(
m_filename).branch_path();
269 std::string log_file_name = boost::filesystem::path(
m_filename).leaf();
271 boost::filesystem::path log_file_path = boost::filesystem::path(
m_filename).parent_path();
272 std::string log_file_name = boost::filesystem::path(
m_filename).filename().string();
274 if (boost::filesystem::exists(log_file_path) && boost::filesystem::is_directory(log_file_path))
277 for (boost::filesystem::directory_iterator it(log_file_path), end; it != end; ++it)
280 if (!is_directory(*it)
282 #
if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
283 && it->leaf().find(log_file_name) == 0
285 && it->path().filename().string().find(log_file_name) == 0
289 boost::filesystem::remove(*it);
307 #if defined(_SYSTEM_POSIX_) && !defined(__ANDROID__) 317 #elif defined(_SYSTEM_WIN32_) static LogOutputStream * create(const icl_core::String &name, const icl_core::String &config_prefix, icl_core::logging::LogLevel log_level=cDEFAULT_LOG_LEVEL)
Represents absolute times.
icl_core::String m_filename
int64_t days() const
Use this function if you want to express the time in days.
virtual void pushImpl(const icl_core::String &log_line)
Base header file for the configuration framework.
#define REGISTER_LOG_OUTPUT_STREAM(name, factory)
bool get< bool >(const icl_core::String &key, bool &value)
Template specialization for boolean values.
int unlink(const char *filename)
ThreadStream & endl(ThreadStream &stream)
int rename(const char *old_filename, const char *new_filename)
void strfTime(char *dest, size_t max_len, const char *format) const
Contains global filesystem related functions, encapsulated into the icl_core::os namespace.
This is an output stream class for log messages.
Contains icl_logging::FileLogOutput.
FileLogOutput(const icl_core::String &name, const icl_core::String &config_prefix, icl_core::logging::LogLevel log_level)
uint32_t m_delete_older_than_days
icl_core::String name() const