Class: Systemdy::Journal
- Inherits:
-
Object
- Object
- Systemdy::Journal
- Extended by:
- SingleForwardable
- Defined in:
- lib/systemdy/journal.rb
Overview
Allows to filter journalctl logs
Constant Summary collapse
- LIST_OF_OPTIONS_THAT_NOT_ACCEPT_ARGUMENTS =
Note:
The meaning of this constant is that in linux the command “‘ journalctl -k “` not accept arguments
list of options for execute journalctl command that not accept arguments
{ kernel: '-k' }
- LIST_OF_OPTIONS_THAT_ACCEPT_AN_ARGUMENT =
Note:
The meaning of this constant is that in linux the command “‘ journalctl -b “` can accept arguments, if executed without argument return the last boot logs
list of options for execute journalctl command that accept arguments
{ boot: '-b' }
- LIST_OF_OPTIONS_THAT_REQUIRE_AN_ARGUMENT =
Note:
The meaning of this constant is that in linux the command like “‘ journalctl -u “` require arguments, if executed without argument return an error
list of options for execute journalctl command that require arguments
{ unit: '-u', group_id: '_GID', user_id: '_UID' }
Class Method Summary collapse
-
.display_boot_logs ⇒ Array
display the boot logs.
-
.display_group_id_logs ⇒ Array
display the group_id logs (GUID).
-
.display_kernel_logs ⇒ Array
display the kernel logs.
-
.display_unit_logs ⇒ Array
display the unit logs.
-
.display_user_id_logs ⇒ Array
display the user_id logs (UID).
Class Method Details
.display_boot_logs ⇒ Array
This method is generated with use of metaprogramming techniques
display the boot logs
69 70 71 72 73 74 75 76 |
# File 'lib/systemdy/journal.rb', line 69 LIST_OF_OPTIONS_THAT_ACCEPT_AN_ARGUMENT.each do |from, option| define_singleton_method "display_#{from}_logs" do |argument: '', since: 'today', to: Time.now.strftime('%H:%M'), lines: 10| # logs from system call logs = `#{JOURNALCTL_COMMAND} #{option} #{argument} -S '#{since}' -U '#{to}' -n #{lines} | tail -n #{lines} 2>&1` # logs from system call converted into array return_an_array_from_system_command(logs) # class method contained in Systemdy/utility/formatter.rb end end |
.display_group_id_logs ⇒ Array
This method require the GUID as argument. For more information check out the examples below
This method is generated with use of metaprogramming techniques
display the group_id logs (GUID)
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/systemdy/journal.rb', line 128 LIST_OF_OPTIONS_THAT_REQUIRE_AN_ARGUMENT.each do |from, option| define_singleton_method "display_#{from}_logs" do |argument: '', since: 'today', to: Time.now.strftime('%H:%M'), lines: 10| # return an error message if the required argument is not provided # render_message class method contained in Systemdy/utility/message_displayer.rb return ("display_#{from}_logs require an argument!") if argument.to_s.empty? # combination of option and argument based on typology # '-u postgresql' or '_GUID=1000' or '_UID=1000' option_with_argument = merge_option_with_argument_based_on_option_typology(from, option, argument) # logs from system call logs = `#{JOURNALCTL_COMMAND} #{option_with_argument} -S '#{since}' -U '#{to}' | tail -n #{lines} 2>&1` # logs from system call converted into array return_an_array_from_system_command(logs) # class method contained in Systemdy/utility/formatter.rb end end |
.display_kernel_logs ⇒ Array
This method is generated with use of metaprogramming techniques
display the kernel logs
41 42 43 44 45 46 47 48 |
# File 'lib/systemdy/journal.rb', line 41 LIST_OF_OPTIONS_THAT_NOT_ACCEPT_ARGUMENTS.each do |from, option| define_singleton_method "display_#{from}_logs" do |since: 'today', to: Time.now.strftime('%H:%M'), lines: 10| # logs from system call logs = `#{JOURNALCTL_COMMAND} #{option} -S '#{since}' -U '#{to}' -n #{lines} | tail -n #{lines} 2>&1` # logs from system call converted into array return_an_array_from_system_command(logs) # class method contained in Systemdy/utility/formatter.rb end end |
.display_unit_logs ⇒ Array
This method require the unit name as argument. For more information check out the examples below
This method is generated with use of metaprogramming techniques
display the unit logs
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/systemdy/journal.rb', line 128 LIST_OF_OPTIONS_THAT_REQUIRE_AN_ARGUMENT.each do |from, option| define_singleton_method "display_#{from}_logs" do |argument: '', since: 'today', to: Time.now.strftime('%H:%M'), lines: 10| # return an error message if the required argument is not provided # render_message class method contained in Systemdy/utility/message_displayer.rb return ("display_#{from}_logs require an argument!") if argument.to_s.empty? # combination of option and argument based on typology # '-u postgresql' or '_GUID=1000' or '_UID=1000' option_with_argument = merge_option_with_argument_based_on_option_typology(from, option, argument) # logs from system call logs = `#{JOURNALCTL_COMMAND} #{option_with_argument} -S '#{since}' -U '#{to}' | tail -n #{lines} 2>&1` # logs from system call converted into array return_an_array_from_system_command(logs) # class method contained in Systemdy/utility/formatter.rb end end |
.display_user_id_logs ⇒ Array
This method require the UID as argument. For more information check out the examples below
This method is generated with use of metaprogramming techniques
display the user_id logs (UID)
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/systemdy/journal.rb', line 128 LIST_OF_OPTIONS_THAT_REQUIRE_AN_ARGUMENT.each do |from, option| define_singleton_method "display_#{from}_logs" do |argument: '', since: 'today', to: Time.now.strftime('%H:%M'), lines: 10| # return an error message if the required argument is not provided # render_message class method contained in Systemdy/utility/message_displayer.rb return ("display_#{from}_logs require an argument!") if argument.to_s.empty? # combination of option and argument based on typology # '-u postgresql' or '_GUID=1000' or '_UID=1000' option_with_argument = merge_option_with_argument_based_on_option_typology(from, option, argument) # logs from system call logs = `#{JOURNALCTL_COMMAND} #{option_with_argument} -S '#{since}' -U '#{to}' | tail -n #{lines} 2>&1` # logs from system call converted into array return_an_array_from_system_command(logs) # class method contained in Systemdy/utility/formatter.rb end end |