Esempio n. 1
0
    char* prefix(char* buffer, const std::size_t len, const char* level)
    {
        const char *threadName = Util::getThreadName();
#ifdef __linux
        const long osTid = Util::getThreadId();
#elif defined IOS
        const auto osTid = pthread_mach_thread_np(pthread_self());
#endif
        Poco::DateTime time;
        snprintf(buffer, len, "%s-%.05lu %.4u-%.2u-%.2u %.2u:%.2u:%.2u.%.6u [ %s ] %s  ",
                    (Source.getInited() ? Source.getId().c_str() : "<shutdown>"),
                    osTid,
                    time.year(), time.month(), time.day(),
                    time.hour(), time.minute(), time.second(),
                    time.millisecond() * 1000 + time.microsecond(),
                    threadName, level);
        return buffer;
    }
Esempio n. 2
0
//----------------------------------------
//	DisplayDateTime
//----------------------------------------
void DisplayDateTime(const Poco::DateTime& dateTime, ScopedLogMessage& msg)
{
	msg.Message(Poco::format("            year = %d", dateTime.year()));
	msg.Message(Poco::format("           month = %d\t(1 to 12)", dateTime.month()));
	msg.Message(Poco::format("             day = %d\t(1 to 31)", dateTime.day()));
	msg.Message(Poco::format("            hour = %d\t(0 to 23)", dateTime.hour()));
	msg.Message(Poco::format("          minute = %d\t(0 to 59)", dateTime.minute()));
	msg.Message(Poco::format("          second = %d\t(0 to 59)", dateTime.second()));
	msg.Message(Poco::format("     millisecond = %d\t(0 to 999)", dateTime.millisecond()));
	msg.Message(Poco::format("     microsecond = %d\t(0 to 999)", dateTime.microsecond()));
	msg.Message(Poco::format("            isAM = %s\t(true or false)", std::string(dateTime.isAM() ? "true":"false")));
	msg.Message(Poco::format("            isPM = %s\t(true or false)", std::string(dateTime.isPM() ? "true":"false")));
	msg.Message(Poco::format("      isLeapYear = %s\t(true or false)", std::string(Poco::DateTime::isLeapYear(dateTime.year()) ? "true":"false")));
	msg.Message(Poco::format("        hourAMPM = %d\t(0 to 12)", dateTime.hourAMPM()));
	msg.Message(Poco::format("       dayOfWeek = %d\t(0 to 6,   0: Sunday)", dateTime.dayOfWeek()));
	msg.Message(Poco::format("       dayOfYear = %d\t(1 to 366, 1: January 1)", dateTime.dayOfYear()));
	msg.Message(Poco::format("     daysOfMonth = %d\t(1 to 366, 1: January 1)", Poco::DateTime::daysOfMonth(dateTime.year(), dateTime.month())));
	msg.Message(Poco::format("            week = %d\t(0 to 53,  1: the week containing January 4)", dateTime.week()));

	msg.Message("");
}