language-extensions/R/src/Logger.cpp
//--------------------------------------------------------------------------------------------------
// Name: Logger::GetCurrentTimestamp
//
// Description:
//  Gets the current system time and format it to the SQL log format
//  (Year-Month-Day Hour:Minute:Second.Millisecond).
//
:GetCurrentTimestamp
Description:
Gets the current system time and format it to the SQL log format
(Year-Month-Day Hour:Minute:Second.Millisecond).
: GetCurrentTimestamp Description : Gets the current system time and format it to the SQL log format ( Year - Month - Day Hour : Minute : Second . Millisecond ) .
const char* Logger::GetCurrentTimestamp()
{
	timespec ts;
	char buffer[TIMESTAMP_LENGTH] = { 0 };
	clock_gettime(CLOCK_REALTIME, &ts);
	strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", gmtime(&ts.tv_sec));
	 Append the milliseconds and the tab to the timestamp
	long ms = (ts.tv_nsec / NANOSECONDS_IN_MILLISECOND);
	 SQL outputs milliseconds in decimal with precision of 2, divide
	 by 10 to remove the last digit.
	ms /= 10;
	 Append the milliseconds and the tab to the timestamp
	sprintf(sm_timestampBuffer, "%s.%02li\t", buffer, ms);
	return sm_timestampBuffer;
}
const char * Logger :: GetCurrentTimestamp ( ) { timespec ts ; char buffer [ TIMESTAMP_LENGTH ] = { 0 } ; clock_gettime ( CLOCK_REALTIME , & ts ) ; strftime ( buffer , sizeof ( buffer ) , " " , gmtime ( & ts . tv_sec ) ) ; long ms = ( ts . tv_nsec / NANOSECONDS_IN_MILLISECOND ) ; ms /= 10 ; sprintf ( sm_timestampBuffer , " \t " , buffer , ms ) ; return sm_timestampBuffer ; }
Name: Logger::GetCurrentTimestamp
Description:
Gets the current system time and format it to the SQL log format
(Year-Month-Day Hour:Minute:Second.Millisecond).
Name : Logger :: GetCurrentTimestamp Description : Gets the current system time and format it to the SQL log format ( Year - Month - Day Hour : Minute : Second . Millisecond ) .
// Convert the time to Year-Month-Day Hour:Minute:Second // // Append the milliseconds and the tab to the timestamp // // SQL outputs milliseconds in decimal with precision of 2, divide // by 10 to remove the last digit. // // Append the milliseconds and the tab to the timestamp //