YaST2 Developers Documentation: YaST2

YaST2

modules/LogView.ycp
Displaying a log with additional functionality
  • Jiri Srain

This module has an unstable interface.

All of these functions watch the log file and display added lines as the log grows.
 LogView::DisplaySimple ("/var/log/messages");
 LogView::DisplayFiltered ("/var/log/messages", "\\(tftp\\|TFTP\\)");
 LogView::Display ($[
          "file" : "/var/log/messages",
          "grep" : "dhcpd",
          "save" : true,
          "actions" : [	// menu buttons
              [ _("Restart DHCP Server"),
                  RestartDhcpDaemon ],
              [ _("Save Settings and Restart DHCP Server"),
                  DhcpServer::Write ],
          ],
      ]);
 

Imports

  • CWM
  • Label
  • LogViewCore
  • Popup
  • Report

Global Functions

Local Variables

Local Functions

local param -> map<string,any>

global parameters for the log displaying widget

local logs -> list<map<string,any> >

list of all the logs that can be displayed

local current_index -> integer

index of currently selected log

local mb_actions -> list<list>

list of actions that can be processed on the logs

local Index2Descr (integer index) -> map<string,any>

Get the map describing the particular log file from its index

Parameters:
index integer index of the log file
Return value:
a map describing the log file
local InitLogReading (integer index) -> void

Starts the log reading command via process agent

Parameters:
index integer the index of the log file
local KillBackgroundProcess (string key) -> void

Kill processes running on the backgrouns

Parameters:
key log widget key
global LogSelectionHelp () -> string

Get the help for the log in case of multiple logs

Return value:
part of the log
global SingleLogHelp () -> string

Get the help for the log in case of a single log

Return value:
part of the log
global AdvancedSaveHelp (string label) -> string

Get the second part of the help for the log in case of advanced functions and save support

Parameters:
label tge label of the menu button
Return value:
part of the log
global AdvancedHelp (string label) -> string

Get the second part of the help for the log in case of advanced functions

Parameters:
label tge label of the menu button
Return value:
part of the log
global SaveHelp () -> string

Get the second part of the help for the log in case of save support

Return value:
part of the log
local CreateHelp (integer logs, map parameters) -> string

Get the help of the widget

Parameters:
logs integer count of displayed logs
parameters map parameters of the log to display
Return value:
help to the widget
local GetLogSelectionCombo (list<map<string,any> > log_maps) -> term

Get the combo box of the available log files

Parameters:
log_maps a list of maps describing all the logs
Return value:
the combo box widget
local GetMenuButtonWidget (list<list> actions, boolean save, string mb_label) -> term

Get the widget with the menu button with actions to be processed on the log

Parameters:
actions a list of all actions
save boolean true if the log should be offered to be saved
mb_label label of the menu button, may be empty for default
Return value:
widget with the menu button
local GetButtonsBelowLog (boolean popup, map<string,any> glob_param, list<map<string,any> > log_maps) -> term

Get the buttons below the box with the log

Parameters:
popup boolean true if running in popup (and Close is needed)
glob_param a map of global parameters of the log widget
log_maps a list of maps describing all the logs
Return value:
the widget with buttons
local GetDefaultItemForLogsCombo (list<map<string,any> > log_maps) -> integer

Get the default entry for the combo box with logs

Parameters:
log_maps a list of maps describing all the logs
Return value:
the index of the default entry in the combo box
local LogSwitch (integer index) -> void

Switch the displayed log

Parameters:
index integer index of the log to display
global LogInit (string key) -> void

Initialize the displayed log

Parameters:
key table widget key
global LogHandle (string key, map event) -> symbol

Handle the event on the log view widget

Parameters:
key log widget key
event map event to handle
Return value:
always nil
global CreateWidget (map<string,any> parameters, list<map<string,any> > log_files) -> map

Get the map with the log view widget

Parameters:
parameters map parameters of the widget to be created, will be unioned with the generated map
  - "save" -- boolean, if true, then log saving is possible
  - "actions" -- list, allows to specify additional actions.
                 Each member is a 2- or 3-entry list, first entry is a
                 label for the menubutton, the second one is a function
                 that will be called when the entry is selected,
                 the signature of the function must be void(),
			optional 3rd argument, if set to true, forces
			restarting of the log displaying command after the
			action is performed
  - "mb_label" -- string, label of the menubutton, if not specified,
                  then "Advanced" is used
  - "max_lines" -- integer, maximum of lines to be displayed. If 0,
                   then display whole file. Default is 100.
  - "help" -- string for a rich text, help to be offered via a popup
              when user clicks the "Help" button. If not present,
              default help is shown or Help button is hidden.
 - "widget_height" -- height of the LogView widget, to be adjusted
                      so that the widget fits into the dialog well.
                      Test it to find the best value, 15 seems to be
                      good value (is default if not specified)
 
log_files a list of logs that will be displayed
  - "file" -- string, filename with the log
  - "grep" -- string, basic regular expression to be grepped
              in the log (for getting relevant  parts of
              /var/log/messages. If empty or not present, whole file
              is used
  - "command" -- allows to specify comand to get the log for cases
                 where grep isn't enough. If used, file and grep entries
                 are ignored
  - "log_label" -- header of the LogView widget, if not set, then the file
                   name or the command is used
  - "default" -- define and set to true to make this log be active after
                 widget is displayed. If not defiend for any log, the
                 first log is automatically default. If defined for multiple
                 logs, the first one is active
 
Return value:
the log widget
global Display (map<string, any> parameters) -> void

Main function for displaying logs

Parameters:
parameters map description of parameters, with following keys
  - "file" -- string, filename with the log
  - "grep" -- string, basic regular expression to be grepped
              in the log (for getting relevant  parts of
              /var/log/messages. If empty or not present, whole file
              is used
  - "command" -- allows to specify command to get the log for cases
                 where grep isn't enough. If used, file and grep entries
                 are ignored
  - "save" -- boolean, if true, then log saving is possible
  - "actions" -- list, allows to specify additional actions.
                 Each member is a 2- or 3-entry list, first entry is a
                 label for the menubutton, the second one is a function
                 that will be called when the entry is selected,
                 the signature of the function must be void(),
			optional 3rd argument, if set to true, forces
			restarting of the log displaying command after the
			action is performed
  - "help" -- string for a rich text, help to be offered via a popup
              when user clicks the "Help" button. If not present,
              Help button isn't shown
  - "mb_label" -- string, label of the menubutton, if not specified,
                  then "Advanced" is used
  - "max_lines" -- integer, maximum of lines to be displayed. If 0,
                   then display whole file. Default is 100.
  - "log_label" -- header of the LogView widget, if not set, then "Log"
                   is used
 
global DisplaySimple (string file) -> void

Display specified file, list 100 lines

Parameters:
file string filename of file with the log
global DisplayFiltered (string file, string grep) -> void

Display log with filtering with 100 lines

Parameters:
file string filename of file with the log
grep string basic regular expression to be grepped in file