Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.log.add
on add (item, logname, flTextFile=user.log.prefs.flLogToTextFile, flOutline=user.log.prefs.flLogToOutline, flGuestDB=user.log.prefs.flLogToGuestDatabase, flwptext=false, flViewLog=user.log.prefs.flViewLog) { <<Changes <<6/13/05; 5:13:59 AM by DW <<If flViewLog is false, don't open new outlines. <<12/14/98; 7:10:21 AM by DW <<rewrote this to run off user.log.prefs <<three booleans specify whether the log is written to a text file, an outline in Frontier.root or to a guest database in ops/logs/ <<writing to the guest database is done thru a call to log.addToGuestDatabase <<Fri, 12 Mar 1999 02:05:16 GMT by AR <<Added optional boolean parameter flViewLog. local (now = clock.now ()); if flTextFile { local (logFolder, s); <<logFolder = file.folderFromPath (frontier.getProgramPath ()) <<logFolder = logFolder + "Logs" + file.getPathChar () logFolder = user.log.prefs.folder; //PBS 2/28/99 if sizeOf (logName) > 26 { logName = string.mid (logName, 1, 26)}; local (logFile = logFolder + logName); if not (logFile endsWith ".txt") { logFile = logFile + ".txt"}; if not (file.exists (logFile)) { file.sureFilePath (logFile); file.new (logFile); local(theOS = sys.os()); if theOS == "MacOS" || theOS == "MacCn" { file.setCreator (logFile, 'R*ch'); file.setType (logFile, 'TEXT')}}; s = now + ": " + item; case sys.os () { "Win95"; "WinNT" { s = string.replaceAll (s, "\r", "\r\n")}}; //add line feeds semaphore.lock (logFile, 600); file.writeLine (logFile, s); semaphore.unlock (logFile)}; if flOutline { local (adroutline = @user.log.outlines.[logname]); semaphores.lock (string (adroutline), 3600); local (oldTarget = target.get ()); if not defined (adroutline^) { new (outlineType, adroutline); if flViewLog { edit (adroutline)}}; on addstring (s) { s = s + "; on " + now; if op.getlinetext () == "" { op.setlinetext (s)} else { op.insert (s, up)}}; target.set (adroutline); op.firstSummit (); case typeof (item) { stringtype { addstring (item)}; listtype { if sizeOf (item) > 0 { local (i, dir = right); addstring (item [1]); for i = 2 to sizeof (item) { op.insert (item [i], dir); dir = down}; if dir == down { op.go (left, 1)}}}} else { try { addstring (string (item))}}; target.set (oldTarget); semaphores.unlock (string (adroutline)); if flViewLog { edit (adroutline)}}; if flGuestDB { local (adrsubtable = log.addToGuestDatabase (logname)); if flwptext { wp.newtextobject (item, @adrsubtable^.item)} else { adrsubtable^.item = item}; if flViewLog { edit (parentof (adrsubtable^)); op.go (down, infinity); op.expand (1)}}}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.