Mailinglist Archive: yast-devel (51 mails)

< Previous Next >
Re: [yast-devel] Assistance with logging and errors in yast-auth-server
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Mon, 25 Mar 2019 07:52:44 +0100
  • Message-id: <20190325075111.0311dd6c@linux-vvcf.privatesite>
V Mon, 25 Mar 2019 12:35:59 +1000
William Brown <wbrown@xxxxxxx> napsáno:

Trimmed, but thanks for the steps, they are added to now so that
future-William will remember :)

Good idea. Maybe you can check also our docs and if you miss there anything
useful, feel free to improve it or ask us to improve it.

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
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 :)

welcome to ruby world. Feel free to also ask ruby questions, there are also a
lot of online sources for 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

so you can use something like

log.debug "If you are interested, I am here, but you probably are not." "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:

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 ...')))
if !DS389.install_pkgs
Popup.Error(_('Error during package installation.'))
# Collect setup parameters into an INI file and feed it into 389 setup
log.debug("+++++++ MARKER ONE +++++++")
ini_content = DS389.gen_setup_ini(fqdn, instance_name, suffix, dm_dn,
log.debug("+++++++ MARKER TWO +++++++")
ini_safe_content = DS389.gen_setup_ini(fqdn, instance_name, suffix,
dm_dn, "********")
log.debug("+++++++ MARKER THREE +++++++")
log.debug("+++++++ MARKER FOUR +++++++")
ok = DS389.exec_setup(ini_content)
log.debug("+++++++ MARKER FIVE +++++++")
if !ok
Popup.Error(_('Failed to set up new instance! Log output may be found
in %s') % [DS_SETUP_LOG_PATH])

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

2019-03-25 12:25:14 <1> linux-jrnj(15991) [Pkg] Setting solver flag 'dupAllowNameChange' to
2019-03-25 12:25:14 <1> linux-jrnj(15991) [Pkg] 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/ Dynamic Proxy:
[UI::ReplaceWidget] with [6] params
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/ Namespace created from UI
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui] overloaded ReplaceWidget, 2@24
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/ Call ReplaceWidget
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/ Append parameter `id (`busy)
2019-03-25 12:25:14 <0> linux-jrnj(15991) [Ruby]
binary/ Append parameter `Empty ()
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui] Actual type: <unspec> (term, term)
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui] Candidate: boolean ReplaceWidget
(symbol, term) MATCH: -1
2019-03-25 12:25:14 <0> linux-jrnj(15991) [ui] 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 … :(

That is strange as usually we log it and also display popup to user when it
reach global exception handler ( uncaught exceptions ). Just try to add to your
code `raise "testing exception"` and you should see it yourself.

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

Well, your problem is too generic exception catcher at
It catches all exceptions, which in general I do not recommend as it catches
beside user errors also programmers ones. At least you can change it to `rescue
RuntimeError`. And for sure always log what you catch unless you re-raise it,
so it is not silent as now.
And because you catch exception, then global exception handler is not in



William Brown

Senior Software Engineer, 389 Directory Server

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

< Previous Next >
Follow Ups