History

streamline system startup logging

Ge Wang committed 3 years ago

Commit f8d387a1 parent 87efd116 files · +130 −69Browse files

Showing the changes to src/core/util_string.cpp (1 of 6 files). Show all

Unified · Split

src/core/util_string.cpp+34−0
@@ -43,6 +43,7 @@ · 42 unmodified lines
43#endif // #ifndef __CHUNREAL_ENGINE__43#endif // #ifndef __CHUNREAL_ENGINE__
44#endif // #ifdef __PLATFORM_WIN32__44#endif // #ifdef __PLATFORM_WIN32__
45 45
46#include <time.h>
46#include <limits.h>47#include <limits.h>
47#include <stdio.h>48#include <stdio.h>
48using namespace std;49using namespace std;
@@ -747,3 +748,36 @@ t_CKBOOL extension_matches( const std::string & filename, const std::string & ex · 698 unmodified lines
747 // return strncmp( extension, filename+(filename_length-extension_length),748 // return strncmp( extension, filename+(filename_length-extension_length),
748 // extension_length ) == 0;749 // extension_length ) == 0;
749}750}
751
752
753
754
755//-----------------------------------------------------------------------------
756// name: timestamp_formatted() | 1.5.0.4 (ge) added
757// desc: return formatted string of current local time; no newline
758//-----------------------------------------------------------------------------
759std::string timestamp_formatted()
760{
761 // timestamp
762 char datetime_buf[32];
763 // how computer sees time
764 time_t datetime;
765 // get local time
766 time( &datetime );
767 // format time
768 const char * timestr = ctime(&datetime);
769 // check if result ok
770 if( !timestr ) return "[unable to determine/format time]";
771
772 // copy formatted date; ctime() always returns fixed length
773 // e.g., "Sat Jun 24 04:18:42 2023" -- 24 characters... okay
774 // what happens when the year becomes 5 or more digits?
775 // in the year 10000...
776 // will there still be computers? or humans? computer music?!?
777 strncpy( datetime_buf, timestr, 24 );
778 // terminate the string
779 datetime_buf[24] = '\0';
780
781 // return the formatted timestamp
782 return datetime_buf;
783}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t