勝手に添削ーpythonだと
http://blog.livedoor.jp/dankogai/archives/50780781.html
なんか流行ってるらしいのでpythonで。
#!/usr/bin/python from datetime import datetime import os,cgi import fcntl f = cgi.FieldStorage() module = f.getvalue("module") func = f.getvalue("func") message = f.getvalue("message") remote_addr = os.environ["REMOTE_ADDR"] now = datetime.now() logfilename = now.strftime("logfile%Y%m%d.log") logtime = now.strftime("%Y/%m/%d %T") logline = "%s %s %s %s %s\n" % (logtime, remote_addr, module, func, message) file = open(logfilename, 'a+') fcntl.flock(file.fileno(), fcntl.LOCK_EX) file.write(logline) fcntl.flock(file.fileno(), fcntl.LOCK_UN) file.close() print "Content-type: text/html"
CGI初めて書いた。danさんのをそのまま書いてみただけ。
pythonだとおもしろくもなんともない。言語的に誰が書いても同じようなコードになるので。
その分悩みがないのかも!?
うくく。