Skip to content

Commit

Permalink
Added cross-platform compatibility for logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Datsuk committed Aug 13, 2024
1 parent 797eef8 commit 42600b0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ihp-sg13g2/libs.tech/klayout/tech/lvs/sg13g2_full.lylvs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ exec_start_time = Time.now
logger = Logger.new($stdout)
# Cross-platform memory usage retrieval
def get_memory_usage
if Gem.win_platform?
`tasklist /FI "PID eq #{Process.pid}" /FO LIST`.lines.find { |line| line.include?("Mem Usage") }.strip
else
`ps -o rss= -p #{Process.pid}`.strip + " KB"
end
end
logger.formatter = proc do |_severity, datetime, _progname, msg|
"#{datetime}: Memory Usage (" + `pmap #{Process.pid} | tail -1`[10, 40].strip + ") : #{msg}
"
"#{datetime}: Memory Usage (" + get_memory_usage + ") : #{msg}\n"
end
#================================================
Expand Down

0 comments on commit 42600b0

Please sign in to comment.