
functions
files
intro
|
|
YaST2 |
modules/LogView.ycp |
| Displaying a log with additional functionality |
|
|
|
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
Global Functions
Local Variables
Local Functions
- CreateHelp (integer logs, map parameters)
- DeleteOldLines (list<string> lines, integer max_lines)
- FillWidgetWithData (integer index)
- GetButtonsBelowLog (boolean popup, map<string,any> glob_param, list<map<string,any> > log_maps)
- GetDefaultItemForLogsCombo (list<map<string,any> > log_maps)
- GetLogSelectionCombo (list<map<string,any> > log_maps)
- GetMaxLines (map<string,any> log_descr)
- GetMenuButtonWidget (list<list> actions, boolean save, string mb_label)
- Index2Descr (integer index)
- InitLogReading (integer index)
- KillBackgroundProcess (string key)
- LogSwitch (integer index)
|
|
|
|
local max_lines_default -> integer
|
|
default value of maximum displayed lines
|
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 lines -> list<string>
|
|
current lines of the selected log
|
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 GetMaxLines (map<string,any> log_descr) -> integer
|
|
Get maximum lines to display for a log
- Parameters:
|
log_descr |
a map describing the log |
- Return value:
|
|
maximum log lines to display |
|
local InitLogReading (integer index) -> void
|
|
Starts the log reading command via background agent
- Parameters:
|
index |
integer the index of the log file |
|
local KillBackgroundProcess (string key) -> void
|
|
Kill processes running on the backgrouns
- Parameters:
|
local DeleteOldLines (list<string> lines, integer max_lines) -> list<string>
|
|
Remove unneeded items from a list
If max_lines is 0, then don't remove anything
- Parameters:
|
lines |
a list of strings representing log lines |
|
max_lines |
integer lines that should be saved |
- Return value:
|
|
a list last max_lines of lines
FIXME probably used in multiple locations!!!
FIXME variables are global, no need to have them as parameters |
|
local FillWidgetWithData (integer index) -> void
|
|
Fills the log widget with initial data got from the background agent
- Parameters:
|
index |
integer index of the log file |
|
global LogSelectionHelp () -> string
|
|
Get the help for the log in case of multiple logs
- Return value:
|
global SingleLogHelp () -> string
|
|
Get the help for the log in case of a single log
- Return value:
|
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:
|
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:
|
global SaveHelp () -> string
|
|
Get the second part of the help for the log in case of save support
- Return value:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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 comand 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 |
|