From f9321f0f073a8d105a431e7175333b1c3a49fa87 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 25 Nov 2015 22:09:41 +0400 Subject: [PATCH] log to stdout --- hangover.rb | 16 ++++------------ smack_my_bitch_up.rb | 19 ++++--------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/hangover.rb b/hangover.rb index 2bc4053..400c0d8 100755 --- a/hangover.rb +++ b/hangover.rb @@ -3,13 +3,6 @@ # Skip on weekends exit if Time.now.saturday? || Time.now.sunday? -log_file_name = File.dirname(__FILE__) + '/logs/hangover.txt' - -# Be sure that logs dir always exists -Dir.mkdir('logs') unless File.exists?(log_file_name) - -LOG_FILE = File.open(log_file_name, 'a+') - # Exit early if sessions with my username are found exit if `who -q`.include? ENV['USER'] @@ -27,19 +20,18 @@ TWILIO_AUTH_TOKEN = ENV['TWILIO_AUTH_TOKEN'] my_number = '+xxx' number_of_boss = '+xxx' -excuses = [ +excuse = [ 'Locked out', 'Pipes broke', 'Food poisoning', 'Not feeling well' -] +].sample # Send a text message @twilio.messages.create( from: my_number, to: number_of_boss, - body: 'Gonna work from home. ' + excuses.sample + body: "Gonna work from home. #{excuse}" ) # Log this -LOG_FILE.puts("Message sent at: #{Time.now}") -LOG_FILE.close +puts "Message sent at: #{Time.now} | Excuse: #{excuse}" diff --git a/smack_my_bitch_up.rb b/smack_my_bitch_up.rb index 0fc5bae..06596e8 100755 --- a/smack_my_bitch_up.rb +++ b/smack_my_bitch_up.rb @@ -3,13 +3,6 @@ # Skip on weekends exit if Time.now.saturday? || Time.now.sunday? -log_file_name = File.dirname(__FILE__) + '/logs/smack_my_bitch_up.txt' - -# Be sure that logs dir always exists -Dir.mkdir('logs') unless File.exists?(log_file_name) - -LOG_FILE = File.open(log_file_name, 'a+') - # Exit early if no sessions with my username are found exit if `who -q`.include? ENV['USER'] @@ -27,20 +20,16 @@ TWILIO_AUTH_TOKEN = ENV['TWILIO_AUTH_TOKEN'] my_number = '+xxx' her_number = '+xxx' -reasons = [ +reason = [ 'Working hard', 'Gotta ship this feature', 'Someone fucked the system again' -] - -sample = reasons.sample +].sample # Send a text message @twilio.messages.create( - from: my_number, to: her_number, body: 'Late at work. ' + sample + from: my_number, to: her_number, body: "Late at work. #{reason}" ) # Log this -LOG_FILE.puts("Message sent at: #{Time.now}") -LOG_FILE.puts("Reason: #{sample}") -LOG_FILE.close +puts "Message sent at: #{Time.now} | Reason: #{reason}"