logout.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
-- 2000/8 LINUX/Sather verion
-- 1996/10 
-- LINUX/Modula2 version
-- 93/06/22 21:43:00
-- Kouji  Kodama    1989/8    
-- Modula2 version

-- logging on a file with displaying on terminal .


class LOGOUT < $OSTREAM

class LOGOUT < $OSTREAM is shared outS:TEXT_FILE; shared LogEnabled:BOOL:=false; shared FileEnabled:BOOL:=false; shared LogFile:STR:=""; create:SAME is res:SAME:=new; return res; end; Connect(inout s:STR) is -- set output file name & open. file:STR; if FileEnabled then Disconnect; end; if ( s.size>0 ) then file:=s; elsif LogFile.size>0 then file:=LogFile; else file:="knotLog."+DATE::year.card.decimal_str+"-"+DATE::mon.str+"-"+DATE::mday.str; end; s:=""; LogFile:=""; if file[0]>' ' then if FILE_SYS::exists(file) then outS:=TEXT_FILE::open_at_end_for_update(file); else outS:=TEXT_FILE::create_for_write(file); outS.close; outS:=TEXT_FILE::open_at_end_for_update(file); end; FileEnabled:=outS.append; if FileEnabled then s:=file; LogFile:=file; else outS.close; end; end; end; Disconnect is if FileEnabled then LogEnabled:=false; FileEnabled:=false; outS.flush; outS.close; end; end; LogBegin is if FileEnabled.not then Connect(inout LogFile); end; LogEnabled:= FileEnabled; end; LogEnd is if FileEnabled then outS.flush; end; LogEnabled:=false; end; is_enabled:BOOL is return LogEnabled; end; LogTime is if LogEnabled then outS+"#DATE"+DATE::year.card.decimal_str+"-"+DATE::mon.str+"-"+DATE::mday.str+"," +DATE::hour.str+":"+DATE::min.str+":"+DATE::sec.str+".\n"; end; end; Title(s1,s2:STR) is #OUT+s1+" "+s2+".\n"; if LogEnabled then outS+"\n"; LogTime; outS+s1+" "+s2+".\n"; end; end; flush is #OUT.flush; if FileEnabled then outS.flush; end; end; plus(s:STR) is #OUT+s; if LogEnabled then outS+s; end; end; plus(s:STR):SAME is plus(s); return self; end; --plus(s:FSTR) is plus(s.str); end; -- plus(s:FSTR):SAME is plus(s); return self; end; end; -- class LOGOUT