카테고리 없음
[루비] 프로그램이 디버그 모드에서 실행 중인지 확인
행복을전해요
2021. 1. 29. 04:36
이것이 내가 한 일입니다.
다음 코드를 (rails) 액션에 넣고 디버그 모드와 비디 버그 모드 모두에서 출력을 비교했습니다.
puts ENV.to_hash.to_yaml
나는 차이점 중 하나가있는 것으로 나타났습니다 ENV['RUBYLIB']
(도있다 IDE_PROCESS_DISPATCHER
, DEBUGGER_STORED_RUBYLIB
, RUBYOPT
, and DEBUGGER_HOST
)
확인하는 방법은 다음과 같습니다.
if ENV['RUBYLIB'] =~ /ruby-debug-ide/
puts 'in debug mode'
else
puts 'not in debug mode'
end
-------------------전역 변수가 필요합니다 $LOAD_PATH
.
a = $LOAD_PATH
a.each do |current_path|
puts 'Debug mode' if current_path.include?('rb/gems')
end
$LOAD_PATH
"/home/username/RubyMine-6.0.2/rb/gems"
디버그 모드를 사용하면 이 줄이 있습니다.
출처
https://stackoverflow.com/questions/22039807