Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30726

Re: final question: logging to stdout and updating files

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <maniandram01@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'handler': 0.04; 'output': 0.04; 'frameworks': 0.05; '[0]': 0.07; 'compile-time': 0.07; 'parameter': 0.07; 'subject:question': 0.08; 'python': 0.09; 'changed;': 0.09; 'logger': 0.09; 'stderr': 0.09; 'subject:files': 0.09; "they've": 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'django': 0.10; "wouldn't": 0.11; 'file,': 0.15; 'also:': 0.16; 'bouncing': 0.16; 'compress': 0.16; 'detects': 0.16; 'occurs,': 0.16; 'reload': 0.16; 'world;': 0.16; 'wrote:': 0.17; 'circular': 0.17; 'url:dev': 0.17; 'thanks,': 0.18; 'handles': 0.18; 'module': 0.19; 'variable': 0.20; 'import': 0.21; 'all:': 0.22; 'tells': 0.22; 'help.': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'example': 0.23; 'errors': 0.23; 'player': 0.23; "i've": 0.23; 'seems': 0.23; 'command': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'logging': 0.27; 'core': 0.27; 'c++': 0.27; 'module.': 0.27; "doesn't": 0.28; 'issues.': 0.29; 'project:': 0.29; 'questions.': 0.29; 'reporting': 0.29; 'url:code': 0.29; "i'm": 0.29; 'that.': 0.30; 'usually': 0.30; 'thursday,': 0.30; 'writes': 0.30; 'error': 0.30; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; "aren't": 0.33; 'curious': 0.33; 'skip:l 40': 0.33; 'problem': 0.33; 'code:': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'screen': 0.34; 'skip:l 30': 0.35; 'so,': 0.35; 'doing': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'loaded': 0.36; 'url:library': 0.36; 'possible': 0.37; 'keeps': 0.37; 'october': 0.37; 'does': 0.37; 'received:209': 0.37; 'far': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'object': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'things': 0.38; 'url:docs': 0.38; 'sure': 0.38; 'build': 0.39; 'bottom': 0.60; 'back': 0.62; 'between': 0.63; 'url:p': 0.63; 'world': 0.63; 'hang': 0.65; 'harder': 0.65; 'forth': 0.75; 'everything,': 0.84; 'light-weight': 0.84; 'players,': 0.84; 'received:209.85.216.184': 0.84; 'recovery.': 0.84; 'rooms': 0.84; 'care,': 0.91; 'this;': 0.91
Newsgroups comp.lang.python
Date Thu, 4 Oct 2012 06:34:28 -0700 (PDT)
In-Reply-To <mailman.1781.1349320295.27098.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=122.167.227.18; posting-account=uPFZNQoAAAAm9w7z13q1SjWNKNjztdcD
References <mailman.1781.1349320295.27098.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 122.167.227.18
MIME-Version 1.0
Subject Re: final question: logging to stdout and updating files
From Ramchandra Apte <maniandram01@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.1797.1349357671.27098.python-list@python.org> (permalink)
Lines 89
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349357671 news.xs4all.nl 6942 [2001:888:2000:d::a6]:34231
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30726

Show key headers only | View raw


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.

Solution for the logging problem is to use to use logging.handlers.BaseRotatingHandler [0]
^0 http://docs.python.org/dev/library/logging.handlers.html#baserotatinghandler

"Optimize code always even if it causes bugs" - Ramchandra Apte, 2001-

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

final question: logging to stdout and updating files "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-10-03 21:11 -0600
  Re: final question: logging to stdout and updating files Ramchandra Apte <maniandram01@gmail.com> - 2012-10-04 00:53 -0700
  Re: final question: logging to stdout and updating files Ramchandra Apte <maniandram01@gmail.com> - 2012-10-04 00:53 -0700
  Re: final question: logging to stdout and updating files Ramchandra Apte <maniandram01@gmail.com> - 2012-10-04 06:34 -0700
  Re: final question: logging to stdout and updating files Ramchandra Apte <maniandram01@gmail.com> - 2012-10-04 06:34 -0700
    Re: final question: logging to stdout and updating files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-04 14:00 +0000
      Re: final question: logging to stdout and updating files Chris Angelico <rosuav@gmail.com> - 2012-10-05 00:27 +1000
      RE: final question: logging to stdout and updating files "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-04 22:36 +0000
      Re: final question: logging to stdout and updating files Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-05 09:11 +0100
      Re: final question: logging to stdout and updating files Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-05 09:19 +0100
      Re: final question: logging to stdout and updating files Ramchandra Apte <maniandram01@gmail.com> - 2012-10-05 06:32 -0700
  Re: final question: logging to stdout and updating files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-04 14:52 +0000

csiph-web