Output and logging from Autobahn|Python components

#1

Just a general question on output/logging: What do you folks use for logging from your application components? I see that some examples use twisted.python.log. Is there any particular reason to use that logging mechanism in Autobahn components, instead of say the regular Python logging module?

There’s no logging mechanism in Autobahn itself (or Crossbar) intended for application level logging, right? Each application author should choose a logging mechanism just like he/she normally would?

Cheers,

Elvis

0 Likes

#2

Elvis,

I have a question open on the Crossbar google group about this as well: https://groups.google.com/forum/#!topic/crossbario/gt_JLPcFxmU

Seems there IS a way to configure this in the crossbar config, but I am seeing that it doesn’t always print from backend python to stdout…

I haven’t seen any real movement on my question on the other group so I’m hoping posting here and sharing my experience will raise awareness.

-Dave

0 Likes

#3

Hi Dave,

Yes I saw your post on the Crossbar list, but thanks for the heads up. Lets hope someone gets around to answering, but activity seems pretty low on all the lists, and I have several unanswered (and old) mails :frowning:

Elvis

···

On Monday, April 27, 2015 at 9:49:58 PM UTC+2, Dave Thomas wrote:

Elvis,

I have a question open on the Crossbar google group about this as well: https://groups.google.com/forum/#!topic/crossbario/gt_JLPcFxmU

Seems there IS a way to configure this in the crossbar config, but I am seeing that it doesn’t always print from backend python to stdout…

I haven’t seen any real movement on my question on the other group so I’m hoping posting here and sharing my experience will raise awareness.

-Dave

0 Likes

#4

Opened: https://github.com/crossbario/crossbar/issues/314

0 Likes

#5

https://bugs.python.org/issue11633 and https://docs.python.org/2/using/cmdline.html#cmdoption-u are related.

If you set PYTHONUNBUFFERED=1 in your config, logging works as-expected. Perhaps crossbar should just set this env-var automagically? To immediately fix the issue described, add a config snippit like this to your guest:

"options"    : {
"env"        : {
"vars"            : {
"PYTHONUNBUFFERED": "1"
        }
}
}

Crossbar config.json required a string of “1”, it would not accept JSON Int 1

You can also add "-u" to the arguments list (instead of the env-var).

         {
"id": "backend"         ,
"type": "guest"         ,
"executable": "python3"         ,
"arguments": ["backend.py"         ],
"options"            : {
"env"               : {
"vars"                  : {
"PYTHONUNBUFFERED": "1"
               }
},
"workdir": "../backend"            ,
"stdout": "log"            ,
"stderr": "log"            ,
"watch"               : {
"directories": ["../backend"               ],
"action": "restart"
            }
}
}
0 Likes