Module: IdZebra

Defined in:
lib/idzebra.rb

Defined Under Namespace

Modules: Native Classes: Repository, TransactionError

Class Method Summary collapse

Class Method Details

.API(config_file) {|Repository.new(zh)| ... } ⇒ Object

Create a new Repository connection.

Yields:



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/idzebra.rb', line 77

def API(config_file, &block)
  extend Native
  log_level = :error
  zs = zebra_start(config_file)
  zh = zebra_open(zs, nil)
  log_level = :default
  yield Repository.new(zh)
  log_level = :error
  zebra_close zh
  zebra_stop zs
end

.log_levelObject

Get the current logging level



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/idzebra.rb', line 90

def log_level
  extend Native
  mask = yaz_log_mask_str('')
  case mask
  when yaz_log_mask_str('none,error')
    :error
  when yaz_log_mask_str('none,error,warn')
    :warn
  when yaz_log_mask_str('log')
    :info
  when yaz_log_mask_str('all')
    :default
  else
    mask
  end
end

.log_level=(log_level) ⇒ Object

Set the logging level



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/idzebra.rb', line 108

def log_level=(log_level)
  extend Native
  case log_level
  when Numeric
    yaz_log_init_level(log_level)
  when :error
    yaz_log_init_level(yaz_log_mask_str('none,error'))
  when :warn
    yaz_log_init_level(yaz_log_mask_str('none,error,warn'))
  when :info, :default
    yaz_log_init_level(yaz_log_mask_str('log'))
  when :debug, :all
    yaz_log_init_level(yaz_log_mask_str('all,zebraapi,flock'))
  end
end