colortail 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.markdown CHANGED
@@ -1,4 +1,10 @@
1
- ### colortail 0.1.2 2010-04-19
1
+ ### colortail 0.1.4 2010-04-21
2
+
3
+ * CTRL-C now properly caught
4
+ * Threads are now cleaned properly
5
+ * List available groupings from the command line
6
+
7
+ ### colortail 0.1.3 2010-04-19
2
8
 
3
9
  * BUGFIX: Ensure config file exists before sourcing it
4
10
 
data/README.markdown CHANGED
@@ -31,7 +31,7 @@ The full list of choices for colors and combinations are listed below.
31
31
  * blue
32
32
  * magenta - (purple-ish)
33
33
  * cyan
34
- * white
34
+ * light gray
35
35
 
36
36
  #### Attributes ####
37
37
 
@@ -42,6 +42,19 @@ The full list of choices for colors and combinations are listed below.
42
42
  * reverse
43
43
  * hidden - simply don't show the text
44
44
 
45
+ #### Additional Colors ####
46
+
47
+ To get the additional colorset listed below, use the **bright** attribute.
48
+
49
+ * dark gray (bright black)
50
+ * light blue (bright blue)
51
+ * light green (bright green)
52
+ * light cyan (bright cyan)
53
+ * light red (bright red)
54
+ * light purple (bright purle)
55
+ * yellow (bright brown)
56
+ * white (bright light gray)
57
+
45
58
  ### Configuration Example ###
46
59
 
47
60
  The example given in the configuration file is good for tailing a syslog file that has lines that are naemd with their syslog level. There are a lot of potential uses. Check the wiki page of [example groupings](http://www.codaset.com/elubow/colortail/wiki/example-groupings) to see how others are using ColorTail.
@@ -60,7 +73,7 @@ The command below will tail the **/var/log/messages** file using the syslog grou
60
73
 
61
74
  ColorTail intentionally does not die when a file specified on the command line doesn't exist.
62
75
 
63
- ## Additionial Information ##
76
+ ## Additional Information ##
64
77
 
65
78
  * Homepage: [http://www.codaset.com/elubow/colortail](http://www.codaset.com/elubow/colortail)
66
79
  * Wiki: [Home](http://www.codaset.com/elubow/colortail/wiki)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/colortail.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{colortail}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Eric Lubow"]
12
- s.date = %q{2010-04-19}
12
+ s.date = %q{2010-04-21}
13
13
  s.default_executable = %q{colortail}
14
14
  s.description = %q{Tail a file and color lines based on regular expressions within that line. By setting up multiple expression and color groups in the configuration file, you can apply highlighting to a file while its being tailed.}
15
15
  s.email = %q{eric@lubow.org}
@@ -25,7 +25,13 @@ module ColorTail
25
25
  @match_group = config.load_opts(options[:group])
26
26
  else
27
27
  # Create this to ensure we always have a value for this array
28
- @match_group = Array.new
28
+ @match_group = Array.push( 'default' => [] )
29
+ end
30
+
31
+ # Display the list of available groups and exit
32
+ if options[:list]
33
+ config.display_match_groups()
34
+ return 1
29
35
  end
30
36
 
31
37
  logger = ColorTail::Colorize.new()
@@ -39,7 +45,6 @@ module ColorTail
39
45
  logger.add_color_matcher( @match_group )
40
46
  end
41
47
 
42
-
43
48
  # Create a thread for each file
44
49
  threads = []
45
50
  files.each do |file|
@@ -53,6 +58,7 @@ module ColorTail
53
58
  # Tail the file and show new lines
54
59
  tailer.tail { |line| logger.log( file, line ) }
55
60
  }
61
+ threads[files.index(file)].run
56
62
  end
57
63
 
58
64
  # Let the threads do their real work
@@ -60,10 +66,21 @@ module ColorTail
60
66
  thread.join
61
67
  end
62
68
 
69
+ # If we get a CTRL-C, catch it (rescue) and send it for cleanup
70
+ rescue Interrupt
71
+ cleanup(threads)
63
72
  end
64
73
 
65
74
  return 0
66
75
  end
76
+
77
+ def cleanup(threads)
78
+ threads.each do |thread|
79
+ thread.kill
80
+ end
81
+ $stderr.puts "Terminating..."
82
+ exit
83
+ end
67
84
  end
68
85
  end
69
86
 
@@ -33,6 +33,13 @@ module ColorTail
33
33
  end
34
34
  return colorset
35
35
  end
36
+
37
+ def display_match_groups()
38
+ puts "The following match groups are available through your config files:"
39
+ Groupings.each_key do |group|
40
+ puts " * #{group}"
41
+ end
42
+ end
36
43
  end
37
44
 
38
45
  class ComplexRecord < StandardError
@@ -52,17 +59,22 @@ module ColorTail
52
59
 
53
60
  require 'optparse'
54
61
  @opts = OptionParser.new do |o|
55
- o.banner = "Usage: #{File.basename($0)} <file>"
62
+ o.banner = "Usage: #{File.basename($0)} <file1> <file2> ..."
56
63
 
57
64
  options[:group] = 'default'
58
65
  o.on( '-g', '--group <group>', 'Specify the color grouping to use for these files' ) do |group|
59
66
  options[:group] = group
60
67
  end
61
68
 
69
+ options[:list] = false
70
+ o.on( '-l', '--list', 'List all the available color groupings' ) do |group|
71
+ options[:list] = true
72
+ end
73
+
62
74
  o.separator ""
63
75
 
64
76
  options[:conf] = "#{user_home}/.colortailrc"
65
- o.on( '-c', '--conf <FILE>', 'Specify an alternate config file' ) do |file|
77
+ o.on( '-c', '--conf <file>', 'Specify an alternate config file' ) do |file|
66
78
  if File.exists?(file)
67
79
  options[:conf] = file
68
80
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colortail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Lubow
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-19 00:00:00 -04:00
12
+ date: 2010-04-21 00:00:00 -04:00
13
13
  default_executable: colortail
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency