Mailinglist Archive: yast-devel (51 mails)

< Previous Next >
Re: [yast-devel] Assistance with logging and errors in yast-auth-server
Trimmed, but thanks for the steps, they are added to README.md now so that
future-William will remember :)

On 22 Mar 2019, at 16:25, Josef Reidinger <jreidinger@xxxxxxx> wrote:

it is really easy. Simply include to your class Y2Logger to your class and
then you can use method log method to pass things to logger.

so e.g. at
https://github.com/Firstyear/yast-auth-server/blob/2019-03-19-update-ds-create/src/lib/authserver/ui/new_dir_inst.rb#L28
you already have it ( but if I can comment code I do not think it is good
idea to include whole Yast namespace to class due to some class collisions
with ruby world ),

Well, I didn’t do that, thats the original module author … I’m willing to fix
it, but one step at a time. This is my first time using ruby :)

so without inclusion of whole Yast it will look `include Yast::Logger`.
And then you can simply use our logger, which has identical API as ruby
logger: https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html

so you can use something like

log.debug "If you are interested, I am here, but you probably are not."
log.info "JFYI: I am here"
log.warn "Hey! I am here."
log.error "I am here and you have problem.”

I have replaced the internals of the “custom” error log functions now with
log.debug (temporarily), and later I’ll replace all the append_to_log calls
with these properly.




My branch and work can be found:

https://github.com/Firstyear/yast-auth-server/tree/2019-03-19-update-ds-create


Feel free to upen draft pull request on github and ask us for code review. We
can give you bunch of hints, tips and resources how to improve code.

Thanks I may just do that.

Right now, I have updated the branch, with some log messages to see how far we
get:

UI.ReplaceWidget(Id(:busy), Label(_('Installing new instance, this may take
a minute ...')))
begin
if !DS389.install_pkgs
Popup.Error(_('Error during package installation.'))
raise
end
# Collect setup parameters into an INI file and feed it into 389 setup
script
log.debug("+++++++ MARKER ONE +++++++")
ini_content = DS389.gen_setup_ini(fqdn, instance_name, suffix, dm_dn,
dm_pass)
log.debug("+++++++ MARKER TWO +++++++")
ini_safe_content = DS389.gen_setup_ini(fqdn, instance_name, suffix,
dm_dn, "********")
log.debug("+++++++ MARKER THREE +++++++")
log.debug(ini_safe_content)
log.debug("+++++++ MARKER FOUR +++++++")
ok = DS389.exec_setup(ini_content)
log.debug("+++++++ MARKER FIVE +++++++")
DS389.remove_setup_ini
if !ok
Popup.Error(_('Failed to set up new instance! Log output may be found
in %s') % [DS_SETUP_LOG_PATH])
raise
end

Now looking at .y2log (run with Y2DEBUG=1):

2019-03-25 12:25:14 <1> linux-jrnj(15991) [Pkg]
Package.cc(set_solver_flag):1824 Setting solver flag 'dupAllowNameChange' to
enabled
2019-03-25 12:25:14 <1> linux-jrnj(15991) [Pkg]
Package.cc(set_solver_flag):1824 Setting solver flag 'dupAllowVendorChange' to
disabled
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby] ui/new_dir_inst.rb:103 +++++++
MARKER ONE +++++++
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/Yast.cc(ycp_module_call_ycp_function):282 Dynamic Proxy:
[UI::ReplaceWidget] with [6] params
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/Yast.cc(ycp_module_call_ycp_function):291 Namespace created from UI
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui]
YUINamespace.cc(createFunctionCall):1035 overloaded ReplaceWidget, 2@24
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/Yast.cc(ycp_module_call_ycp_function):326 Call ReplaceWidget
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/Yast.cc(ycp_module_call_ycp_function):332 Append parameter `id (`busy)
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/Yast.cc(ycp_module_call_ycp_function):332 Append parameter `Empty ()
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui]
YUINamespace.cc(finishParameters):915 Actual type: <unspec> (term, term)
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui]
YUINamespace.cc(finishParameters):932 Candidate: boolean ReplaceWidget (symbol,
term) MATCH: -1
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui]
YUINamespace.cc(finishParameters):932 Candidate: boolean ReplaceWidget (term,
term) MATCH: 0

The “gen_setup_ini” is failing due to wrong number of arguments, but there is
*zero* indication of this in the .y2log. It looks like any ruby exception or
errors just go into a vacuum … :(

Is there something I’m missing in YaST to show ruby exceptions or errors?



Sincerely,

William Brown

Senior Software Engineer, 389 Directory Server
SUSE Labs

--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups