final question: logging to stdout and updating files

Ramchandra Apte maniandram01 at gmail.com
Thu Oct 4 03:53:49 EDT 2012


On Thursday, 4 October 2012 08:41:35 UTC+5:30, Littlefield, Tyler  wrote:
> pHello all:
> 
> I've seen frameworks like django reload files when it detects that 
> 
> they've been changed; how hard would it be to make my engine reload 
> 
> files that it detects were changed? I'm also curious how hard it would 
> 
> be to build in some error recovery. For example right now when an 
> 
> exception occurs, the player is sometimes just left hanging. It's a lot 
> 
> harder with Python for me, because I don't get the compile-time errors 
> 
> that I would with c++ for example to know that I did something wrong; 
> 
> while that's not always useful/and by far it doesn't catch everything, 
> 
> it does help. I'm familiar with things like pychecker, but it seems to 
> 
> be reporting a lot of issues that aren't issues. For example, I have a 
> 
> world module which is the core of the engine; it handles players, as 
> 
> well as keeps tracks of all rooms that are loaded in the game and that. 
> 
> Because player and world would have circular imports, I just pass the 
> 
> world object into player functions like logon/create. Pychecker tells me 
> 
> that the world parameter (which is a local var at that point) shadows 
> 
> the world variable in world; world is a singleton, so when you import 
> 
> world it just has a world = World() at the bottom of the module.
> 
> 
> 
> also: I have the following code:
> 
>      logging.basicConfig(filename=path.join("logs", "mud.log"), 
> 
> level=logging.DEBUG)
> 
>      logger = logging.getLogger(__name__)
> 
>      logger.addHandler(logging.StreamHandler())
> 
> I like it displaying to stderr since usually when I'm doing this I'm in 
> 
> screen bouncing back and forth between the output and the tt++ session, 
> 
> but right now I can't get a couple of things; I'm not sure how to set it 
> 
> to log and all other messages to stderr as I did for the file, and I'd 
> 
> like to use a rotating log handler so that it'll rotate when the files 
> 
> are say above 16 KB or something. Is it possible to do something like 
> 
> this; perhaps make it compress the file before it writes to disk, or 
> 
> call a command to do so, so that it wouldn't hang the entire mud while 
> 
> it compresses?
> 
> Thanks, and sorry again for all the questions.
> 
> 
> 
> -- 
> 
> Take care,
> 
> Ty
> 
> http://tds-solutions.net
> 
> The aspen project: a barebones light-weight mud engine:
> 
> http://code.google.com/p/aspenmud
> 
> He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

I use pylint with NINJA IDE. NINJA IDE automatically shows common problems.



More information about the Python-list mailing list