You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: gist-logs.rb
    path of file: ./repos/brew/Library/Homebrew/cmd
    
    the code of the file until where you have to start completion: #:  * `gist-logs` [`--new-issue`|`-n`] [`--private`|`-p`] <formula>:
#:    Upload logs for a failed build of <formula> to a new Gist.
#:
#:    <form
    
  def load_logs(dir)
    logs = {}
    if dir.exist?
      dir.children.sort.each do |file|
        contents = file.size? ? file.read : "empty log"
        # small enough to avoid GitHub "unicorn" page-load-timeout errors
        max_file_size = 1_000_000
        contents = truncate_text_to_approximate_size(contents, max_file_size, front_weight: 0.2)
        logs[file.basename.to_s] = { content: contents }
      end
    end