- Timestamp:
- 05/22/15 10:28:08 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/logger.cc
r365 r368 142 142 void log_console_sink::log( log_level level, const string_ref& message ) 143 143 { 144 char stamp[16]; 145 size_t ssize = timestamp( stamp ); 146 144 147 #if NV_PLATFORM == NV_WINDOWS 145 148 if ( m_color ) SetConsoleTextAttribute( m_handle, FOREGROUND_INTENSITY ); 146 string_ref stamp( timestamp() ); 147 WriteConsole( m_handle, stamp.data(), stamp.size(), nullptr, nullptr ); 149 WriteConsole( m_handle, stamp, ssize, nullptr, nullptr ); 148 150 WriteConsole( m_handle, " [", 2, nullptr, nullptr ); 149 151 if (m_color) SetConsoleTextAttribute( m_handle, log_color[( level ) / 10] ); … … 156 158 #else 157 159 if ( m_color ) fwrite( "\33[30;1m", 7, 1, stdout ); 158 fwrite( stamp .data(), stamp.size(), 1, stdout );160 fwrite( stamp, ssize, 1, stdout ); 159 161 fwrite( " [", 2, 1, stdout ); 160 162 if ( m_color ) … … 176 178 void log_handle_sink::log( log_level level, const string_ref& message ) 177 179 { 178 string_ref stamp( timestamp() ); 180 char stamp[16]; 181 size_t ssize = timestamp( stamp ); 179 182 #if 0 // NV_PLATFORM == NV_WINDOWS 180 183 // Turns out WriteFile on Windows is unbuffered and quite slower than fwrite … … 182 185 // If we want to get rid of C runtime, this would need a buffered I/O layer. 183 186 DWORD unused = 0; 184 WriteFile( m_handle, stamp .data(), stamp.size(), &unused, nullptr );187 WriteFile( m_handle, stamp, ssize, &unused, nullptr ); 185 188 WriteFile( m_handle, " [", 2, &unused, nullptr ); 186 189 WriteFile( m_handle, NV_LOG_LEVEL_NAME_PAD( level ), 8, &unused, nullptr ); … … 190 193 //if ( m_flush ) FlushFileBuffers( m_handle ); 191 194 #else 192 fwrite( stamp .data(), stamp.size(), 1, (FILE*)m_handle );195 fwrite( stamp, ssize, 1, (FILE*)m_handle ); 193 196 fwrite( " [", 2, 1, (FILE*)m_handle ); 194 197 fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, (FILE*)m_handle ); … … 237 240 } 238 241 239 s tring_ref nv::log_sink::timestamp() const242 size_t nv::log_sink::timestamp( char* buffer ) const 240 243 { 241 244 uint32 ms = get_system_ms(); … … 245 248 unsigned int m = (unsigned int)(secs / 60) % 60; 246 249 unsigned int s = secs % 60; 247 static char buffer[16];248 250 #if NV_PLATFORM == NV_WINDOWS 249 251 sprintf_s( buffer, 16, "%02d:%02d:%02d.%02d", h, m, s, mm ); … … 251 253 snprintf( buffer, 16, "%02d:%02d:%02d.%02d", h, m, s, mm ); 252 254 #endif 253 buffer[11] = '\0'; 254 return string_ref( buffer, 10 ); 255 return 11; 255 256 } 256 257 -
trunk/src/engine/program_manager.cc
r365 r368 6 6 7 7 #include "nv/engine/program_manager.hh" 8 #include "nv/ core/range.hh"8 #include "nv/stl/range.hh" 9 9 #include "nv/core/logging.hh" 10 10 #include "nv/lua/lua_nova.hh" -
trunk/src/engine/resource_system.cc
r364 r368 6 6 7 7 #include "nv/engine/resource_system.hh" 8 #include "nv/ core/range.hh"8 #include "nv/stl/range.hh" 9 9 #include "nv/lua/lua_nova.hh" 10 10 -
trunk/src/formats/nmd_loader.cc
r323 r368 7 7 #include "nv/formats/nmd_loader.hh" 8 8 #include "nv/io/std_stream.hh" 9 #include "nv/ core/string.hh"9 #include "nv/stl/string.hh" 10 10 11 11 using namespace nv; -
trunk/src/lib/gl.cc
r365 r368 6 6 7 7 #include "nv/core/common.hh" 8 #include "nv/ core/range.hh"8 #include "nv/stl/range.hh" 9 9 #include "nv/core/logging.hh" 10 10 #include "nv/lib/gl.hh" -
trunk/src/lua/lua_area.cc
r335 r368 8 8 9 9 #include "nv/lua/lua_raw.hh" 10 #include "nv/ core/string.hh"10 #include "nv/stl/string.hh" 11 11 #include "nv/core/random.hh" 12 12 -
trunk/src/lua/lua_flags.cc
r319 r368 8 8 9 9 #include "nv/lua/lua_raw.hh" 10 #include "nv/ core/string.hh"10 #include "nv/stl/string.hh" 11 11 12 12 -
trunk/src/lua/lua_glm.cc
r319 r368 8 8 9 9 #include "nv/lua/lua_raw.hh" 10 #include "nv/ core/string.hh"10 #include "nv/stl/string.hh" 11 11 #include "nv/core/random.hh" 12 12 -
trunk/src/lua/lua_map_area.cc
r360 r368 6 6 7 7 #include "nv/lua/lua_map_area.hh" 8 #include "nv/ core/flags.hh"8 #include "nv/stl/flags.hh" 9 9 #include "nv/lua/lua_area.hh" 10 10 #include "nv/lua/lua_glm.hh" -
trunk/src/lua/lua_map_tile.cc
r323 r368 9 9 #include <numeric> 10 10 #include "nv/lua/lua_map_area.hh" 11 #include "nv/ core/flags.hh"11 #include "nv/stl/flags.hh" 12 12 #include "nv/core/random.hh" 13 13 #include "nv/lua/lua_area.hh" -
trunk/src/lua/lua_raw.cc
r319 r368 7 7 #include "nv/lua/lua_raw.hh" 8 8 9 #include "nv/ core/string.hh"9 #include "nv/stl/string.hh" 10 10 11 11 std::string nlua_typecontent( lua_State* L, int idx ) -
trunk/src/lua/lua_state.cc
r367 r368 10 10 #include "nv/lua/lua_nova.hh" 11 11 #include "nv/core/logging.hh" 12 #include "nv/ core/string.hh"12 #include "nv/stl/string.hh" 13 13 14 14 using namespace nv; -
trunk/src/rogue/fov_recursive_shadowcasting.cc
r319 r368 7 7 #include "nv/rogue/fov_recursive_shadowcasting.hh" 8 8 9 #include "nv/ core/math.hh"9 #include "nv/stl/math.hh" 10 10 11 11 static int nv_rogue_rs_mult[4][8] = { -
trunk/src/sdl/sdl_audio.cc
r367 r368 7 7 #include "nv/sdl/sdl_audio.hh" 8 8 9 #include "nv/ core/math.hh"9 #include "nv/stl/math.hh" 10 10 #include "nv/lib/sdl_mixer.hh" 11 11 #include "nv/core/logging.hh" -
trunk/src/stl/string.cc
r367 r368 7 7 // TODO: speedup conversion by doing divisions by 100 8 8 9 #include "nv/ core/string.hh"9 #include "nv/stl/string.hh" 10 10 11 11 #include <cstdio>
Note: See TracChangeset
for help on using the changeset viewer.