Skip to content

Commit

Permalink
logging: migrated all references from pyjamas.log -> pyjamas.logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bittner committed Apr 9, 2012
1 parent 4594990 commit 2f217fd
Show file tree
Hide file tree
Showing 35 changed files with 167 additions and 138 deletions.
4 changes: 3 additions & 1 deletion addons/DeferredHandler.py
Expand Up @@ -5,7 +5,9 @@
"""

from pyjamas.Timer import Timer
from pyjamas import log
from pyjamas import logging

log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

global deferredHandlers
deferredHandlers = []
Expand Down
12 changes: 7 additions & 5 deletions addons/FlowPlayer.py
Expand Up @@ -14,7 +14,9 @@
from pyjamas.Timer import Timer
import urllib
from __pyjamas__ import wnd
from pyjamas import log
from pyjamas import logging

log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

"""
Global variables called by Flash External Interface
Expand Down Expand Up @@ -196,7 +198,7 @@ def __createFlashVars(self, config):
#config_string = config_string.replace('<', '&lt;')
#config_string = config_string.replace('>', '&gt;')
config_string = config_string.replace('\'', '\\\'')
#log.writebr(config_string)
#log.debug(config_string)
return config_string

def fireEvent(self, movieName, eventName, arguments):
Expand All @@ -205,9 +207,9 @@ def fireEvent(self, movieName, eventName, arguments):
Fire event
"""
#log.writebr('FireEvent: %s/%s/%s' % (movieName, eventName, str(arguments)))
#log.debug('FireEvent: %s/%s/%s' % (movieName, eventName, str(arguments)))
if eventName == 'testFireEvent':
log.writebr('fireEvent works')
log.debug('fireEvent works')
return
if eventName == 'onLoad' and arguments[0] == 'player':
self.loadApi()
Expand Down Expand Up @@ -251,7 +253,7 @@ def fireEvent(self, movieName, eventName, arguments):
DeferredHandler.add(eventMethod, [])
clip.fireEvent(eventName, arguments[2:])
else:
#log.writebr('[FP Event] %s / %s' % (eventName, arguments))
#log.debug('[FP Event] %s / %s' % (eventName, arguments))
if hasattr(listener, eventName):
eventMethod = getattr(listener, eventName)
DeferredHandler.add(eventMethod, arguments)
Expand Down
19 changes: 10 additions & 9 deletions addons/RichTextEditor.py
Expand Up @@ -5,14 +5,15 @@
FCKeditor javascript.
"""

from pyjamas import Window
from pyjamas import DOM
from pyjamas import log
from BoundMethod import BoundMethod
from pyjamas import logging
from pyjamas import DOM
from pyjamas import Window
from pyjamas.ui.Widget import Widget

from __pyjamas__ import JS

log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)


def createFCK(name):
JS("""
Expand Down Expand Up @@ -106,22 +107,22 @@ def onFCKLoaded(self, fck):
self.pendingHTML = None

def onSelectionChange(self, sender):
pass#log.writebr("onSelectionChange!")
pass#log.debug("onSelectionChange!")

def onBlur(self, sender):
pass#log.writebr("onBlur!")
pass#log.debug("onBlur!")

def onFocus(self, sender):
pass#log.writebr("onFocus!")
pass#log.debug("onFocus!")

def onPaste(self, sender):
pass#log.writebr("onPaste!")
pass#log.debug("onPaste!")

def onSave(self):
"""
Handle the save click and pass it onto the listeners.
"""
log.writebr("onSave() in %s", Window.getLocation().getHref())
log.debug("onSave() in %s", Window.getLocation().getHref())
for listener in self.saveListeners:
if hasattr(listener, "onSave"):
listener.onSave(self)
Expand Down
Expand Up @@ -10,13 +10,7 @@
from pyjamas import logging
log = logging.getConsoleLogger() # other loggers: Alert, Append, Print ...
...
log.error("Hello, here is an error")
</pre>
<p>To make your life even easier there's also a convenience module that
provides an AppendLogger with simple text output already by default:</p>
<pre class="code">
from pyjamas import log
log.info('Show this text and value %s now', value)
log.error("Hello, here is an %s error", err_name)
</pre>
<p>For a good understanding of the logging module read the
<a href="http://docs.python.org/howto/logging.html">Python
Expand Down
17 changes: 9 additions & 8 deletions doc/pyjs_site/website.py
@@ -1,8 +1,8 @@
import pyjd # dummy in pyjs

from pyjamas import logging
from pyjamas import DeferredCommand
from pyjamas import History
from pyjamas import logging
from pyjamas import Window
from pyjamas.HTTPRequest import HTTPRequest
from pyjamas.ui import Event
Expand All @@ -22,8 +22,8 @@
from pyjamas.ui.VerticalPanel import VerticalPanel
from PageLoader import PageListLoader, PageLoader

# global logger. Set level to DEBUG to see the log.debug() messages too!
log = logging.getPrintLogger('pyjs_site', logging.INFO)
# global logger. Set level higher than DEBUG to see less logging messages
log = logging.getConsoleLogger()

#class PrettyTab(DecoratorPanel):
class PrettyTab(Composite):
Expand Down Expand Up @@ -87,6 +87,7 @@ def execute(self):
def onWindowResized(self, width, height):

tabwidth = "%dpx" % (width - 350)
log.info('New tab control width = %s <a href="foo.bar">foo.bar</a>', tabwidth)
#width = "%dpx" % (width-20)
#self.header.setWidth(width)
#self.dock.setCellWidth(self.header, width)
Expand All @@ -96,13 +97,12 @@ def onWindowResized(self, width, height):
self.dock.setCellWidth(self.fTabs, tabwidth)

def createPage(self, title, purpose, text):

log.debug("create page %s %s %s", title, purpose, text)
#log.debug("create page %s %s %s", title, purpose, text)
if purpose == 'faq':
self.faq_pages[title] = text
log.debug("%d %d", len(self.faq_pages), len(self.faq_list))
log.debug(self.faq_pages.keys())
log.debug(self.faq_list)
#log.debug(self.faq_pages.keys())
#log.debug(self.faq_list)
if len(self.faq_pages) != len(self.faq_list):
return
faq = self.page_widgets['FAQ']
Expand Down Expand Up @@ -151,7 +151,7 @@ def createPage(self, title, purpose, text):

History.addHistoryListener(self)
initToken = History.getToken()
log.info("initial token: '%s'", initToken)
log.debug("initial token: '%s'", initToken)
self.onHistoryChanged(initToken)
self.fTabs.addTabListener(self)

Expand All @@ -171,6 +171,7 @@ def onHistoryChanged(self, token):

def onError(self, text, code):
log.error("LOAD ERROR(%s): %s", str(code), text)
pass

def loadPageList(self):
HTTPRequest().asyncGet("sidebar.html",
Expand Down
4 changes: 3 additions & 1 deletion examples/asteroids/Space.py
Expand Up @@ -28,7 +28,7 @@
#from pyjamas.Canvas2D import Canvas, CanvasImage, ImageLoadListener
from pyjamas.Timer import Timer
from pyjamas import Window
from pyjamas import log
#from pyjamas import logging
from pyjamas.ui import Event
from pyjamas.ui import KeyboardListener
from pyjamas.ui.KeyboardListener import KeyboardHandler
Expand All @@ -40,6 +40,8 @@
import pygwt
import random

#log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

NUM_ASTEROIDS = 2
FPS = 30
ROTATE_SPEED_PER_SEC = math.pi
Expand Down
7 changes: 4 additions & 3 deletions examples/clickoverride/Override.py
Expand Up @@ -12,8 +12,9 @@
from pyjamas.ui.ClickListener import ClickHandler
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui import Event
from pyjamas import log
from pyjamas import DOM
from pyjamas import logging
log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

class Board(VerticalPanel, ClickHandler):
def __init__(self):
Expand All @@ -34,7 +35,7 @@ def __init__(self):
self.setBorderWidth(1)

def onClick(self, sender):
log.writebr('Text'+str(sender))
log.debug('Text'+str(sender))

def _event_targets_title(self, event):
target = DOM.eventGetTarget(event)
Expand All @@ -55,7 +56,7 @@ def __init__(self, text):
self.addClickListener(self)

def onClick(self, sender):
log.writebr('Text'+str(sender))
log.debug('Text'+str(sender))


if __name__ == "__main__":
Expand Down
Binary file modified examples/flowpanel/public/images/pyjamas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions examples/gwtcanvas/LogoDemo.py
Expand Up @@ -26,7 +26,8 @@

from SimpleCanvasDemo import SimpleCanvasDemo

#from pyjamas import log
#from pyjamas import logging
#log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

class LogoDemoControls(Composite):
def __init__(self):
Expand Down Expand Up @@ -83,14 +84,14 @@ def drawDemo(self):
# Go ahead and animate
if self.isImageLoaded(self.img):
self.run = True
#log.writebr("already loaded")
#log.debug("already loaded")
Timer(1, self)
else:
Window.alert("Refresh the page to reload the image.")


def onImagesLoaded(self, imageHandles):
#log.writebr("loaded")
#log.debug("loaded")
# Drawing code involving images goes here
self.img = imageHandles[0]
self.run = True
Expand All @@ -113,8 +114,8 @@ def renderingLoop(self):
# Draw starting at position 10, 10
# scaled up by a factor of 2 on the self.canvas (using 200x200 as the
# destination dimensions).
#log.writebr(str(self.img))
#log.writebr(DOM.getAttribute("src"))
#log.debug(str(self.img))
#log.debug(DOM.getAttribute("src"))
#self.canvas.drawImage(self.img, 84, 74, 100, 100, 10, 10, 200, 200)
self.canvas.drawImage(self.img, 84, 74)

Expand All @@ -128,7 +129,7 @@ def renderingLoop(self):

self.canvas.restoreContext()

#log.writebr(str(self.rotation))
#log.debug(str(self.rotation))

def onTimer(self, timer):
if not self.run:
Expand Down
Binary file modified examples/helloworldsplash/public/pyjamas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions examples/jsimport/examplejs.py
Expand Up @@ -8,7 +8,8 @@
# if you ABSOLUTELY MUST use javascript, here's how to do it.
#

from pyjamas import log
from pyjamas import logging
log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

# this simply tells the compiler that the two names are to be dropped
# into the javascript global namespace
Expand All @@ -24,11 +25,11 @@ def main():
global examplevar
#examplevar is actually "out of modules", in a super scope

log.writebr(examplevar)
log.debug(examplevar)
examplevar = 'Altered'
log.writebr(get_examplevar())
log.debug(get_examplevar())

main()

examplevar = "Realtered"
log.writebr(get_examplevar())
log.debug(get_examplevar())
6 changes: 4 additions & 2 deletions examples/kitchensink/KitchenSink.py
@@ -1,15 +1,16 @@
import pyjd # this is dummy in pyjs

from pyjamas import logging
from pyjamas.ui.Button import Button
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HTML import HTML
from pyjamas.ui.DockPanel import DockPanel
from pyjamas.ui import HasAlignment
from pyjamas.ui.Hyperlink import Hyperlink
from pyjamas.ui.VerticalPanel import VerticalPanel
from pyjamas import Window
from pyjamas.ui.Sink import SinkList
from pyjamas import History
from pyjamas import Window
import Info
import Buttons
import Layouts
Expand All @@ -23,7 +24,8 @@
import Frames
import Tabs
from Logger import Logger
from pyjamas import log

log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

class KitchenSink:

Expand Down
3 changes: 2 additions & 1 deletion examples/libtest/BuiltinTest.py
Expand Up @@ -27,7 +27,8 @@ def fget(self):
return (self.r, self.g, self.b)
return property(**locals())

#from pyjamas import log
#from pyjamas import logging
#log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

class C(object):
@property
Expand Down
7 changes: 4 additions & 3 deletions examples/maparea/MapAreaDemo.py
@@ -1,6 +1,7 @@
import pyjd

from pyjamas import DOM
from pyjamas import logging

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HTML import HTML
Expand All @@ -13,7 +14,7 @@
from pyjamas.ui.Image import Image
from pyjamas.ui.ContextMenuPopupPanel import ContextMenuPopupPanel

from pyjamas import log
log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)


class MapAreaDemo:
Expand Down Expand Up @@ -105,7 +106,7 @@ def _mouseActionMessage(self, name, action, x=None, y=None):
#msg = "%s %s (%d,%d)" % (name, action, x, y) # throws JS errors
msg = name + ' ' + action + ' (' + str(x) + ', ' + str(y) + ')'
self.msgarea1.setText(msg)
log.writebr(msg)
log.debug(msg)

def onMouseMove(self, sender, x, y):
self._mouseActionMessage(sender.areaname, "move", x, y)
Expand All @@ -125,7 +126,7 @@ def onMouseLeave(self, sender):
def onClick(self, sender):
msg = "you clicked on baby katie's " + sender.areaname
self.msgarea2.setText(msg)
log.writebr(msg)
log.debug(msg)


if __name__ == '__main__':
Expand Down

0 comments on commit 2f217fd

Please sign in to comment.