Class: GitPusshuTen::Log
- Inherits:
-
Object
- Object
- GitPusshuTen::Log
- Defined in:
- lib/gitpusshuten/log.rb
Class Method Summary collapse
-
.error(message) ⇒ Object
Displays an error message.
-
.gitpusshuten_dir ⇒ Object
Returns the Gitpusshuten directory path.
-
.log_dir ⇒ Object
Returns the Gitpusshuten log directory path.
-
.message(message) ⇒ Object
Displays a regular message.
-
.silent(message) ⇒ Object
Silently logs messages.
-
.standard(message) ⇒ Object
Displays a regular message without prefix.
-
.to_file(message) ⇒ Object
Logs the message to the log file.
-
.warning(message) ⇒ Object
Displays a warning message.
Class Method Details
.error(message) ⇒ Object
Displays an error message
30 31 32 33 34 |
# File 'lib/gitpusshuten/log.rb', line 30 def self.error() = "[error] ".color(:red) + puts to_file end |
.gitpusshuten_dir ⇒ Object
Returns the Gitpusshuten directory path
72 73 74 |
# File 'lib/gitpusshuten/log.rb', line 72 def self.gitpusshuten_dir File.join(Dir.pwd, '.gitpusshuten') end |
.log_dir ⇒ Object
Returns the Gitpusshuten log directory path
78 79 80 |
# File 'lib/gitpusshuten/log.rb', line 78 def self.log_dir File.join(gitpusshuten_dir, 'log') end |
.message(message) ⇒ Object
Displays a regular message
14 15 16 17 18 |
# File 'lib/gitpusshuten/log.rb', line 14 def self.() = "[message] ".color(:green) + puts to_file end |
.silent(message) ⇒ Object
Silently logs messages
38 39 40 |
# File 'lib/gitpusshuten/log.rb', line 38 def self.silent() to_file end |
.standard(message) ⇒ Object
Displays a regular message without prefix
7 8 9 10 |
# File 'lib/gitpusshuten/log.rb', line 7 def self.standard() puts unless .nil? to_file end |
.to_file(message) ⇒ Object
Logs the message to the log file
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gitpusshuten/log.rb', line 44 def self.to_file() return unless .is_a?(String) ## # Don't log if we're not working within the Gitpusshuten directory if File.directory?(gitpusshuten_dir) ## # Create the log directory if it doesn't exist if not File.directory?(log_dir) FileUtils.mkdir_p(log_dir) end ## # Remove all ANSI coloring codes for clean logging .gsub!(/\[\d+m/, '') ## # Log the message to the file (append) File.open(File.join(log_dir, 'gitpusshuten.log'), 'a') do |file| file << "\n#{Time.now.strftime("[%m/%d/%Y %H:%M:%S]")} #{}" end end end |
.warning(message) ⇒ Object
Displays a warning message
22 23 24 25 26 |
# File 'lib/gitpusshuten/log.rb', line 22 def self.warning() = "[warning] ".color(:yellow) + puts to_file end |