V Mon, 25 Mar 2019 12:35:59 +1000 William Brown <[email protected]> napsáno:
> Trimmed, but thanks for the steps, they are added to README.md 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 <[email protected]> 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 :) 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 > > 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 … :( 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 https://github.com/Firstyear/yast-auth-server/blob/2019-03-19-update-ds-create/src/lib/authserver/ui/new_dir_inst.rb#L131 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 reached. Josef > > > — > Sincerely, > > William Brown > > Senior Software Engineer, 389 Directory Server > SUSE Labs > -- To unsubscribe, e-mail: [email protected] To contact the owner, e-mail: [email protected]
