Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'fileutils'
- module Device
- class File
- def write(message)
- open
- @io.write(message) #JSON.pretty_generate(message)
- @io.write("\n"*2)
- close
- end
- def close
- @io.close if @io.present?
- end
- def open
- unless ::File.exist?(::File.dirname(path))
- ::FileUtils.mkdir_p(::File.dirname(path))
- end
- @io = ::File.open(path, ::File::WRONLY | ::File::APPEND | ::File::CREAT)
- @io.binmode
- end
- def path
- @path ||= Settings.custom_logger.file_path.presence || Rails.root.join("log/#{Rails.env}.log")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement