1#!/usr/bin/env ruby 2 3require 'logger' 4 5logfile = 'shifting.log' 6# Max 3 age ... logShifting.log, logShifting.log.0, and logShifting.log.1 7shift_age = 3 8# Shift log file about for each 1024 bytes. 9shift_size = 1024 10 11log = Logger.new(logfile, shift_age, shift_size) 12 13def do_log(log) 14 log.debug('do_log1') { 'd' * rand(100) } 15 log.info('do_log2') { 'i' * rand(100) } 16 log.warn('do_log3') { 'w' * rand(100) } 17 log.error('do_log4') { 'e' * rand(100) } 18 log.fatal('do_log5') { 'f' * rand(100) } 19 log.unknown('do_log6') { 'u' * rand(100) } 20end 21 22(1..10).each do 23 do_log(log) 24end 25 26puts 'See shifting.log and shifting.log.[01].' 27