[yast-devel] [RFC] make Builtins.y2milestone(), y2...() obsolete?
Hi all, another change in yast2-ruby-bindings-3.1.7 is a new Yast::Logger module which wraps Y2Logger mentioned in the previous mail. The module provides standard Ruby logging way [1] for writing into y2log. Example: module Yast class Foo < Client include Yast::Logger def foo # this will be logged into y2log using the usual y2log format # Builtins.y2debug() replacement log.debug "debug" # Builtins.y2milestone() replacement log.info "info" # Builtins.y2error() replacement log.error "error" end end end (See [2] for a real example) The advantages over the Builtins.y2*() are: - it's a standard Ruby way (used also in Rails) - we can easily drop Builtins.y2*() in the future - the Logger API is much more flexible (Logger can log to a different file, STDOUT/STDERR, even a String), can be dynamically changed at run time (set different log level, temporarily enable/disable logging, etc...) (of course, these features do not work currently as it's just a wrapper for y2*(), but that could be changed easily) - the Logger API also supports block parameter for lazy evaluation of the message so e.g. log.debug { "#{(0..10000).to_a}" } has NO performance impact if debug logging is disabled as the string is NOT evaluated. That's nice when you log too much details or log huge data structures. Disadvantages: - the y2*() functions can log different call frame or can log a complete backtrace (but that can be done easily in Ruby and this feature is not used much in Yast) - little bit different log levels, e.g. there is no direct equivalent to y2internal(), on the other hand there is a "fatal" error level (see [3] for the current mapping) Problems which prevent from global change (via a script): - percent place holders (e.g. "%1") do not work, automatic change of the existing code to the new logging style is not trivial - the old logging is used in old tests, automatic replace could potentially break some tests So therefore I'd like to make all Builtins.y2*() functions obsolete and in new code use only the new logging style. And suggest changing the logging when touching the old code (if it does not break tests). What do you think about this proposal? [1] http://www.ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html [2] https://github.com/yast/yast-registration/commit/a0c852743b78ac54562e52e8268... [3] https://github.com/yast/yast-ruby-bindings/pull/97/files#diff-c61ab27bc14ba4... -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On 4.2.2014 11:16, Ladislav Slezak wrote:
Hi all,
another change in yast2-ruby-bindings-3.1.7 is a new Yast::Logger module which wraps Y2Logger mentioned in the previous mail.
The module provides standard Ruby logging way [1] for writing into y2log.
Example:
module Yast class Foo < Client include Yast::Logger
def foo # this will be logged into y2log using the usual y2log format
# Builtins.y2debug() replacement log.debug "debug" # Builtins.y2milestone() replacement log.info "info" # Builtins.y2error() replacement log.error "error" end end end
Thank you, Ladislav! This will help us to push conversion from RYCP to Ruby :) Please check for Builtins.*() versus log.* in code reviews and suggest using the new approach if possible (link to docu / example) would be lovely in that case. Bye Lukas -- Lukas Ocilka, Yast TL, Cloud & Systems Management Department SUSE LINUX s.r.o., Praha -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On 02/04/2014 11:16 AM, Ladislav Slezak wrote:
Hi all,
another change in yast2-ruby-bindings-3.1.7 is a new Yast::Logger module which wraps Y2Logger mentioned in the previous mail.
The module provides standard Ruby logging way [1] for writing into y2log.
Example:
module Yast class Foo < Client include Yast::Logger
def foo # this will be logged into y2log using the usual y2log format
# Builtins.y2debug() replacement log.debug "debug" # Builtins.y2milestone() replacement log.info "info" # Builtins.y2error() replacement log.error "error" end end end
I really like this and think it deserves putting a similar example either directly into the main yast-ruby-bindings README.md or at least on top of the y2logger.rb file as a 'real world' example. This will be useful to every yast developer, even more if it is easier to spot. vlado -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 4.2.2014 14:04, Vladimir Moravec napsal(a):
On 02/04/2014 11:16 AM, Ladislav Slezak wrote:
Hi all,
another change in yast2-ruby-bindings-3.1.7 is a new Yast::Logger module which wraps Y2Logger mentioned in the previous mail.
The module provides standard Ruby logging way [1] for writing into y2log.
Done, the old logging builtins were marked as deprecated.
I really like this and think it deserves putting a similar example either directly into the main yast-ruby-bindings README.md or at least on top of the y2logger.rb file as a 'real world' example. This will be useful to every yast developer, even more if it is easier to spot.
There is an example in y2logger.rb file. Moreover the yardoc documentation is linked, the @deprecated tag contains a link to Yast::Logger (with the example). See details in https://github.com/yast/yast-ruby-bindings/pull/98/files -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Tue, Feb 04, 2014 at 11:16:27AM +0100, Ladislav Slezak wrote:
another change in yast2-ruby-bindings-3.1.7 is a new Yast::Logger module which wraps Y2Logger mentioned in the previous mail.
The latest version of yast2-storage doesn't build on openSUSE 12.3 anymore and it seems to be due to the new logging: Client call failed with 'undefined method `synchronize' for #<Mutex:0x00000000fa0eb0>' and backtrace ["/usr/lib64/ruby/1.9.1/singleton.rb:139:in `instance'", "/usr/lib64/ruby/vendor_ruby/1.9.1/yast/y2logger.rb:70:in `log'", "/usr/share/YaST2/modules/Storage.rb:324:in `InitLibstorage'", "/home/abuild/rpmbuild/BUILD/yast2-storage-3.1.10/testsuite/tests/helper1b.rb:11:in `initialize_helper1b'", "/usr/lib64/ruby/vendor_ruby/1.9.1/yast/yast.rb:135:in `include'", "/home/abuild/rpmbuild/BUILD/yast2-storage-3.1.10/testsuite/tests/empty1.rb:22:in `main'", "/home/abuild/rpmbuild/BUILD/yast2-storage-3.1.10/testsuite/tests/empty1.rb:30:in `<top (required)>'", "/usr/lib64/ruby/vendor_ruby/1.9.1/yast/wfm.rb:184:in `eval'", "/usr/lib64/ruby/vendor_ruby/1.9.1/yast/wfm.rb:184:in `run_client'"] So please either fix the issue or remove openSUSE 12.3 from YaST:Head. Regards, Arvin -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 25.2.2014 10:10, Arvin Schnell napsal(a):
On Tue, Feb 04, 2014 at 11:16:27AM +0100, Ladislav Slezak wrote:
another change in yast2-ruby-bindings-3.1.7 is a new Yast::Logger module which wraps Y2Logger mentioned in the previous mail.
The latest version of yast2-storage doesn't build on openSUSE 12.3 anymore and it seems to be due to the new logging:
Client call failed with 'undefined method `synchronize' for #<Mutex:0x00000000fa0eb0>' and backtrace ["/usr/lib64/ruby/1.9.1/singleton.rb:139:in `instance'",
IIRC I have already seen this error and Josef fixed that for Ruby 2.0 so it seems there is Ruby 1.9 vs. 2.0 incompatibility.
So please either fix the issue or remove openSUSE 12.3 from YaST:Head.
I'd remove 12.3 from YaST:Head as it seems it cannot be simply fixed in 12.3, 13.1 and Factory all together. Josef? -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Tue, 25 Feb 2014 11:43:01 +0100 Ladislav Slezak <lslezak@suse.cz> wrote:
Dne 25.2.2014 10:10, Arvin Schnell napsal(a):
On Tue, Feb 04, 2014 at 11:16:27AM +0100, Ladislav Slezak wrote:
another change in yast2-ruby-bindings-3.1.7 is a new Yast::Logger module which wraps Y2Logger mentioned in the previous mail.
The latest version of yast2-storage doesn't build on openSUSE 12.3 anymore and it seems to be due to the new logging:
Client call failed with 'undefined method `synchronize' for #<Mutex:0x00000000fa0eb0>' and backtrace ["/usr/lib64/ruby/1.9.1/singleton.rb:139:in `instance'",
IIRC I have already seen this error and Josef fixed that for Ruby 2.0 so it seems there is Ruby 1.9 vs. 2.0 incompatibility.
In fact there was hack for 1.9 which breaks 2.0 compatibility, so I removed it. So ruby bindigns have problem to run with ruby 1.9.
So please either fix the issue or remove openSUSE 12.3 from YaST:Head.
I'd remove 12.3 from YaST:Head as it seems it cannot be simply fixed in 12.3, 13.1 and Factory all together. Josef?
I am not against, just we lost last place that allow us to easy point user which want convert their modules from ycp to ruby? Josef -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 25.2.2014 11:57, Josef Reidinger napsal(a):
IIRC I have already seen this error and Josef fixed that for Ruby 2.0 so it seems there is Ruby 1.9 vs. 2.0 incompatibility.
In fact there was hack for 1.9 which breaks 2.0 compatibility, so I removed it. So ruby bindigns have problem to run with ruby 1.9.
Ok, so I'll disable openSUSE-12.3 build target.
So please either fix the issue or remove openSUSE 12.3 from YaST:Head.
I'd remove 12.3 from YaST:Head as it seems it cannot be simply fixed in 12.3, 13.1 and Factory all together. Josef?
I am not against, just we lost last place that allow us to easy point user which want convert their modules from ycp to ruby?
The conversion can be still done using the David's appliance he used for the final YCP => Ruby conversion. -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
participants (5)
-
Arvin Schnell
-
Josef Reidinger
-
Ladislav Slezak
-
Lukas Ocilka
-
Vladimir Moravec