diff --git a/easy_profiler_core/event_trace_win.cpp b/easy_profiler_core/event_trace_win.cpp index 0083f36..432aea9 100644 --- a/easy_profiler_core/event_trace_win.cpp +++ b/easy_profiler_core/event_trace_win.cpp @@ -58,7 +58,10 @@ #include #if EASY_OPTION_LOG_ENABLED != 0 -#include +# include +# ifndef EASY_ETW_LOG +# define EASY_ETW_LOG ::std::cerr +# endif #endif ////////////////////////////////////////////////////////////////////////// @@ -275,7 +278,7 @@ namespace profiler { #if EASY_OPTION_LOG_ENABLED != 0 if (!success) - ::std::cerr << "Warning: EasyProfiler failed to set " << _privelegeName << " privelege for the application.\n"; + EASY_ETW_LOG << "Warning: EasyProfiler failed to set " << _privelegeName << " privelege for the application.\n"; #endif return success; @@ -295,7 +298,7 @@ namespace profiler { #if EASY_OPTION_LOG_ENABLED != 0 const bool success = setPrivilege(hToken, SE_DEBUG_NAME); if (!success) - ::std::cerr << "Warning: Some context switch events could not get process name.\n"; + EASY_ETW_LOG << "Warning: Some context switch events could not get process name.\n"; #else setPrivilege(hToken, SE_DEBUG_NAME); #endif @@ -305,7 +308,7 @@ namespace profiler { #if EASY_OPTION_LOG_ENABLED != 0 else { - ::std::cerr << "Warning: EasyProfiler failed to open process to adjust priveleges.\n"; + EASY_ETW_LOG << "Warning: EasyProfiler failed to open process to adjust priveleges.\n"; } #endif } @@ -358,26 +361,26 @@ namespace profiler { } #if EASY_OPTION_LOG_ENABLED != 0 - ::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_ALREADY_EXISTS. To stop another session execute cmd: logman stop \"" << KERNEL_LOGGER_NAME << "\" -ets\n"; + EASY_ETW_LOG << "Error: EasyProfiler.ETW not launched: ERROR_ALREADY_EXISTS. To stop another session execute cmd: logman stop \"" << KERNEL_LOGGER_NAME << "\" -ets\n"; #endif return EVENT_TRACING_WAS_LAUNCHED_BY_SOMEBODY_ELSE; } case ERROR_ACCESS_DENIED: #if EASY_OPTION_LOG_ENABLED != 0 - ::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_ACCESS_DENIED. Try to launch your application as Administrator.\n"; + EASY_ETW_LOG << "Error: EasyProfiler.ETW not launched: ERROR_ACCESS_DENIED. Try to launch your application as Administrator.\n"; #endif return EVENT_TRACING_NOT_ENOUGH_ACCESS_RIGHTS; case ERROR_BAD_LENGTH: #if EASY_OPTION_LOG_ENABLED != 0 - ::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_BAD_LENGTH. It seems that your KERNEL_LOGGER_NAME differs from \"" << m_properties.sessionName << "\". Try to re-compile easy_profiler or contact EasyProfiler developers.\n"; + EASY_ETW_LOG << "Error: EasyProfiler.ETW not launched: ERROR_BAD_LENGTH. It seems that your KERNEL_LOGGER_NAME differs from \"" << m_properties.sessionName << "\". Try to re-compile easy_profiler or contact EasyProfiler developers.\n"; #endif return EVENT_TRACING_BAD_PROPERTIES_SIZE; } #if EASY_OPTION_LOG_ENABLED != 0 - ::std::cerr << "Error: EasyProfiler.ETW not launched: StartTrace() returned " << startTraceResult << ::std::endl; + EASY_ETW_LOG << "Error: EasyProfiler.ETW not launched: StartTrace() returned " << startTraceResult << ::std::endl; #endif return EVENT_TRACING_MISTERIOUS_ERROR; } @@ -418,7 +421,7 @@ namespace profiler { if (m_openedHandle == INVALID_PROCESSTRACE_HANDLE) { #if EASY_OPTION_LOG_ENABLED != 0 - ::std::cerr << "Error: EasyProfiler.ETW not launched: OpenTrace() returned invalid handle.\n"; + EASY_ETW_LOG << "Error: EasyProfiler.ETW not launched: OpenTrace() returned invalid handle.\n"; #endif return EVENT_TRACING_OPEN_TRACE_ERROR; }