[Fab-user] print vs. logging

2009-10-25 Thread Yann Malet
Hello Bruno,

I might be a bit late to comment on this thread but I am giving it a try
now. I have been working lately on trying to scratch this itch. The result
of this can be tested/forked from here :
http://bitbucket.org/yml/fabric_factory/

And the question you asked is the main pain point. You will find here the
particular approach I have used :
http://bitbucket.org/yml/fabric_factory/src/tip/src/worker/__init__.py#cl-105

Ideally I would like an api where I can call a task and get back the output
and the error instead of having to hack sys.stdout and sys.stderr.

Regards,
Yann
___
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user


Re: [Fab-user] print vs. logging

2009-10-25 Thread Jeff Forcier
Hi Yann,

When you first mentioned this need I recall pointing you to
@capture_streams, but since you're still talking about the issue I
went back and realized why it's probably not working out as well as I
thought it would. The result is this exploratory ticket:

http://code.fabfile.org/issues/show/71

Please feel free to provide feedback there if you have a preference
for which approach to take, or alternate ones I haven't thought of
yet. (Still waking up this morning :))

Best,
Jeff

On Fri, Oct 23, 2009 at 11:41 AM, Yann Malet yann.ma...@gmail.com wrote:

 [...]

 Ideally I would like an api where I can call a task and get back the output
 and the error instead of having to hack sys.stdout and sys.stderr.


___
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user


Re: [Fab-user] print vs. logging

2009-10-16 Thread Christian Vest Hansen
On Thu, Oct 15, 2009 at 9:11 PM, Bruno Clermont
bruno.clerm...@gmail.com wrote:
 Hi,

 Thanks for Fabric! With it, I wrote many deployment scripts. Once I
 considered it stable enough, I wrote a django web interface to let my
 users easily invoke those fabric scripts. I just import fabric
 directly from my views, set fabric.state.env.host_string and
 fabric.state.env.key_filename before running the equivalent of a
 fabfile.py.

Don't you risk being bitten by the globally shared mutable state that
is `env`? I mean, what if two people simultaneously start two
different scripts?


 It work perfectly.

 The only thing that don't fit is the way fabric print output of
 operations. It print straight into stdout.

 Is it feasible to use python logging module instead of print?

 Instead of something like (from fabric.operations._run_command):

    if output.debug:
        print([%s] run: %s % (env.host_string, wrapped_command))
    elif output.running:
        print([%s] run: %s % (env.host_string, given_command))

 having a:

    env.log.debug([%s] run: %s % (env.host_string, wrapped_command))
    env.log.info([%s] run: %s % (env.host_string, given_command))

 and give the user the ability to alter the behavior of env.log (such
 as send to a file, syslog and stdout).
 by default just send to the local console at logging.INFO level.

 Maybe It's a bad idea... I don't know, I always used python scripts
 for my own needs... in my case, I've used env.__dict__['log'] =
 logging.getLogger('fabric') to have a global log handler for all my
 classes. Using python logging give so much flexibility to the user,
 while keeping the code clean.

 I quickly hacked a clone git for fun and migrate all print to logging
 and it seem to work fine.

 What do you think of this?


 ___
 Fab-user mailing list
 Fab-user@nongnu.org
 http://lists.nongnu.org/mailman/listinfo/fab-user




-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.


___
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user


Re: [Fab-user] print vs. logging

2009-10-15 Thread Jeff Forcier
Hi Bruno,

On Thu, Oct 15, 2009 at 3:11 PM, Bruno Clermont
bruno.clerm...@gmail.com wrote:
 Hi,

 The only thing that don't fit is the way fabric print output of
 operations. It print straight into stdout.

 Is it feasible to use python logging module instead of print?

I've definitely been considering working the logging module in
sometime, probably in the way you mention, and for the same reason --
library use. As you noticed, right now the code is largely
CLI-oriented.

Looks like I have a ticket in this general area:

http://code.fabfile.org/issues/show/57

Feel free to add comments to that, and/or a link to your clone if it's
up on Github, or a patch attachment or whatever :)

Otherwise, just know that for version 1.0 (which is likely to follow
0.9 closely-ish -- i.e. shouldn't be another 6+ month wait) I'll be
focusing on this sort of library-oriented feature set.

Thanks,
Jeff


___
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user