Exemplo n.º 1
0
	void save(SArchive &s_archive, const MLB::Utility::TimeT &datum,
		const unsigned int)
{
	std::string tmp_datum = datum.ToString();

	s_archive
		& boost::serialization::make_nvp("dateTime", tmp_datum);
}
Exemplo n.º 2
0
//	////////////////////////////////////////////////////////////////////////////
void LogHandlerFileBase::OpenFile(const char *base_name, const char *dir_name,
	const MLB::Utility::TimeT &start_time)
{
	std::string file_name;

	if ((base_name == NULL) || (!(*base_name)))
		file_name = "LogFile.";
	else {
		file_name = base_name;
		if (base_name[strlen(base_name) - 1] != '.')
			file_name += '.';
	}

	std::string tmp_date_time(start_time.ToString());

	tmp_date_time[10]  = '.';
	tmp_date_time[13]  = '.';
	tmp_date_time[16]  = '.';
	file_name         += tmp_date_time + "." + GetHostNameCanonical() + "." +
		AnyToString(CurrentProcessId()) + ".log";

	boost::filesystem::path tmp_file(file_name, boost::filesystem::native);

	if ((dir_name != NULL) && *dir_name) {
		std::string tmp_dir_name;
		ResolveFilePathGeneral(dir_name, tmp_dir_name, "", true, true, false);
		boost::filesystem::path tmp_path(tmp_dir_name, boost::filesystem::native);
		boost::filesystem::path this_file;
		this_file        = tmp_path / tmp_file;
		file_name        = this_file.native_file_string();
	}
	else {
		if (!tmp_file.has_root_path())
			tmp_file = boost::filesystem::system_complete(tmp_file);
		file_name = tmp_file.native_file_string();
	}

	OpenFile(file_name);
}
Exemplo n.º 3
0
// ////////////////////////////////////////////////////////////////////////////
std::string CoreDumperBase::DecorateBaseName(const char *file_name_base,
	MLB::Utility::ProcessId process_id, const std::string &host_name,
	const MLB::Utility::TimeT &time_stamp)
{
	std::string tmp_base;

	if ((file_name_base == NULL) || (!(*file_name_base))) {
		try {
			GetProcessExecutableName(tmp_base);
			tmp_base = MLB::Utility::GetFileNamePortion(tmp_base);
#ifdef _Windows
			std::string::size_type base_size = tmp_base.size();
			if (base_size > 4) {
				if ((!stricmp(tmp_base.data() + (base_size - 4), ".EXE")) ||
					(!stricmp(tmp_base.data() + (base_size - 4), ".COM")))
					tmp_base.assign(tmp_base, 0, base_size - 4);
			}
#elif _VMS_
			std::string::size_type base_size = tmp_base.size();
			if (base_size > 4) {
				if (!stricmp(tmp_base.data() + (base_size - 4), ".COM"))
					tmp_base.assign(tmp_base, 0, base_size - 4);
			}
#endif // #ifdef _Windows
		}
		catch (const std::exception &) {
		}
		if (tmp_base.empty())
			tmp_base = "_UNSPECIFIED_CORE_DUMP_NAME_";
	}
	else {
		tmp_base = file_name_base;
		tmp_base = MLB::Utility::GetFileNamePortion(tmp_base);
#ifdef _Windows
		std::string::size_type base_size = tmp_base.size();
		if (base_size > 4) {
			if ((!stricmp(tmp_base.data() + (base_size - 4), ".EXE")) ||
				(!stricmp(tmp_base.data() + (base_size - 4), ".COM")))
				tmp_base.assign(tmp_base, 0, base_size - 4);
		}
#elif _VMS_
		std::string::size_type base_size = tmp_base.size();
		if (base_size > 4) {
			if (!stricmp(tmp_base.data() + (base_size - 4), ".COM"))
				tmp_base.assign(tmp_base, 0, base_size - 4);
		}
#endif // #ifdef _Windows
	}

	tmp_base = MLB::Utility::GetFileNamePortion(tmp_base);
	tmp_base = MLB::Utility::Trim(tmp_base, ". \t\r\n\v\f");

	if (tmp_base.empty())
		tmp_base = "_UNSPECIFIED_CORE_DUMP_NAME_";

	std::string time_string(time_stamp.ToString());

	time_string[10]  = '.';
	time_string[13]  = '.';
	time_string[16]  = '.';
	tmp_base         = "CoreDump." + tmp_base + "." + time_string + "." +
		host_name + "." + MLB::Utility::ZeroFill(process_id, 10);

	return(tmp_base);
}