from filecache import FileCache, FCPath
from pdslogger import PdsLogger, file_handler
fc = FileCache(cache_name=None)
fcpath1 = fc.new_path('gs://rms-filecache-tests-writable/pdslogger1.log')
fcpath1.unlink(missing_ok=True)
fcpath2 = fc.new_path('gs://rms-filecache-tests-writable/pdslogger2.log')
fcpath2.unlink(missing_ok=True)
pl = PdsLogger.get_logger('gs_test', level='debug', blanklines=False)
handler1 = file_handler(fcpath1, level='debug')
pl.add_handler(handler1)
pl.error('First level error')
pl.open('Second level header name')
handler2 = file_handler(fcpath2, level='debug')
pl.add_handler(handler2)
pl.warning('Second level warning')
pl.error('Second level error')
print('Calling close')
pl.close()
pl.info('First level info')
print('Calling close')
pl.close()
fc.delete_cache()
print()
print('At exit')
print('*** Log 1')
print(fcpath1.read_text())
print()
print('*** Log 2')
print(fcpath2.read_text())
