Mailinglist Archive: yast-devel (53 mails)

< Previous Next >
[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.


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 "info"
# Builtins.y2error() replacement
log.error "error"

(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
but that could be changed easily)

- the Logger API also supports block parameter for lazy evaluation of the
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


- the y2*() functions can log different call frame or can log a complete
(but that can be done easily in Ruby and this feature is not used much in

- 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
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
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?



Ladislav Slez√°k
Appliance department / YaST Developer
Lihovarsk√° 1060/12
190 00 Prague 9 / Czech Republic
tel: +420 284 028 960
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >