Mercurial > traipse
annotate orpg/tools/orpg_log.py @ 27:51428d30c59e ornery-orc
Traipse 'OpenRPG' {091003-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on
code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc''s main goal is to
offer more advanced features and enhance the productivity of the user.
Update Summary:
Adds menu changes to draw attention to important updates, errors, or other events.
Traipse URL is now included in the repos tab and is set as default.
Fixes Copy for Windows and Linux (finally!!) users.
Fixes incomplete update to Grid and List nodes.
Fixes incomplete update to Chat Commands.
Fixes problems with Remote Image Upload.
Fixes Drop and Drag of Minis to Map.
CherryPy can now use any image in the webfiles/ folder and sub-folders.
CherryPy can now Drop and Drag Minis to the Map.
Minor changes to Update Manager's GUI.
Expert recommendation warning added to Revision Update.
Step down compatibility with open_rpg & component added to orpgCore.
Fixes CherryPit misspelling.
Makes Traipse Suite 'Attention' item portable, and executes it on 'Critical' debug notices.
Adds incomplete Shift + Enter to Text Entry, currently creates a 'Critical' warning.
New default Lobby Map, designed for Traipse. Feel free to change it.
Updates to Server GUI:
* Admin can Ban from Backend.
* Admin can Modify Ban List and Un Ban users.
* Server GUI finds your Lobby Name
* New users default as Lurker unless a Role is set
Cleaner TraipseSuiteAttention portability and clean up in Main.
Die Roll Commands addition from Core code allowing Math Ordering with ()'s
New About Dialog. A more uniform About Dialog.
Corrects image loading of duplicate images.
author | sirebral |
---|---|
date | Sat, 03 Oct 2009 18:49:37 -0500 |
parents | 97265586402b |
children | ff154cf3350c |
rev | line source |
---|---|
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
1 # Copyright (C) 2000-2001 The OpenRPG Project |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
2 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
3 # openrpg-dev@lists.sourceforge.net |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
4 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
5 # This program is free software; you can redistribute it and/or modify |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
6 # it under the terms of the GNU General Public License as published by |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
7 # the Free Software Foundation; either version 2 of the License, or |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
8 # (at your option) any later version. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
9 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
10 # This program is distributed in the hope that it will be useful, |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
13 # GNU General Public License for more details. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
14 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
15 # You should have received a copy of the GNU General Public License |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
16 # along with this program; if not, write to the Free Software |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
18 # -- |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
19 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
20 # File: orpg_log.py |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
21 # Author: Dj Gilcrease |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
22 # Maintainer: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
23 # Version: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
24 # $Id: orpg_log.py,v 1.9 2007/05/06 16:43:02 digitalxero Exp $ |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
25 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
26 # Description: classes for orpg log messages |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
27 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
28 |
18 | 29 from __future__ import with_statement |
30 import sys, os, os.path, wx, time, traceback | |
31 | |
32 from orpg.orpgCore import component | |
33 from orpg.external.terminalwriter import TerminalWriter | |
34 from orpg.tools.decorators import pending_deprecation | |
35 from orpg.dirpath import dir_struct | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
36 |
18 | 37 ######################### |
38 ## Error Types | |
39 ######################### | |
40 ORPG_CRITICAL = 1 | |
41 ORPG_GENERAL = 2 | |
42 ORPG_INFO = 4 | |
43 ORPG_NOTE = 8 | |
44 ORPG_DEBUG = 16 | |
45 | |
46 def Crash(type, value, crash): | |
47 crash_report = open(dir_struct["home"] + 'crash-report.txt', "w") | |
48 traceback.print_exception(type, value, crash, file=crash_report) | |
49 crash_report.close() | |
50 msg = '' | |
51 crash_report = open(dir_struct["home"] + 'crash-report.txt', "r") | |
52 for line in crash_report: msg += line | |
53 logger.exception(msg) | |
54 crash_report.close() | |
55 logger.exception("Crash Report Created!!") | |
56 logger.info("Printed out crash-report.txt in your System folder", True) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
57 |
18 | 58 class DebugConsole(wx.Frame): |
59 def __init__(self, parent): | |
27 | 60 super(DebugConsole, self).__init__(parent, -1, "Debug Console") |
18 | 61 icon = None |
62 icon = wx.Icon(dir_struct["icon"]+'note.ico', wx.BITMAP_TYPE_ICO) | |
63 self.SetIcon( icon ) | |
64 self.console = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE | wx.TE_READONLY) | |
65 sizer = wx.BoxSizer(wx.VERTICAL) | |
66 sizer.Add(self.console, 1, wx.EXPAND) | |
67 self.SetSizer(sizer) | |
68 self.SetAutoLayout(True) | |
69 self.SetSize((300, 175)) | |
70 self.Bind(wx.EVT_CLOSE, self.Min) | |
71 self.Min(None) | |
72 component.add('debugger', self.console) | |
73 | |
74 def Min(self, evt): | |
75 self.Hide() | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
76 |
18 | 77 class orpgLog(object): |
78 _log_level = 7 | |
79 _log_name = None | |
80 _log_to_console = False | |
81 _io = TerminalWriter(sys.stderr) | |
82 _lvl_args = None | |
83 | |
84 def __new__(cls, *args, **kwargs): | |
85 it = cls.__dict__.get("__it__") | |
86 if it is not None: | |
87 return it | |
88 cls.__it__ = it = object.__new__(cls) | |
89 return it | |
90 | |
91 def __init__(self, home_dir, filename='orpgRunLog '): | |
92 self._lvl_args = {16: {'colorizer': {'green': True}, | |
93 'log_string': 'DEBUG'}, | |
94 8: {'colorizer': {'bold': True, 'green':True}, | |
95 'log_string':'NOTE'}, | |
96 4: {'colorizer': {'blue': True}, | |
97 'log_string': 'INFO'}, | |
98 2: {'colorizer': {'red': True}, | |
99 'log_string': 'ERROR'}, | |
100 1: {'colorizer': {'bold': True, 'red': True}, | |
101 'log_string': 'EXCEPTION'}} | |
102 if not self.log_name: | |
103 self.log_name = home_dir + filename + time.strftime('%m-%d-%Y.txt', | |
104 time.localtime(time.time())) | |
105 | |
106 def debug(self, msg, to_console=False): | |
107 self.log(msg, ORPG_DEBUG, to_console) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
108 |
18 | 109 def note(self, msg, to_console=False): |
110 self.log(msg, ORPG_NOTE, to_console) | |
111 | |
112 def info(self, msg, to_console=False): | |
113 self.log(msg, ORPG_INFO, to_console) | |
114 | |
115 def general(self, msg, to_console=False): | |
116 self.log(msg, ORPG_GENERAL, to_console) | |
117 | |
118 def exception(self, msg, to_console=True): | |
27 | 119 ### Beta ### Every 'Critical' exception will draw attention to the Debug Console |
120 component.get('frame').TraipseSuiteWarn('debug') | |
18 | 121 self.log(msg, ORPG_CRITICAL, to_console) |
122 | |
123 def log(self, msg, log_type, to_console=False): | |
124 if self.log_to_console or to_console or log_type == ORPG_CRITICAL: | |
125 try: self._io.line(str(msg), **self._lvl_args[log_type]['colorizer']) | |
126 except: pass #Fails without the Debug Console | |
127 try: component.get('debugger').AppendText(".. " + str(msg) +'\n') | |
128 except: pass | |
129 | |
130 if log_type & self.log_level or to_console: | |
131 atr = {'msg': msg, 'level': self._lvl_args[log_type]['log_string']} | |
132 atr['time'] = time.strftime('[%x %X]', time.localtime(time.time())) | |
133 logMsg = '%(time)s (%(level)s) - %(msg)s\n' % (atr) | |
134 | |
135 with open(self.log_name, 'a') as f: | |
136 f.write(logMsg) | |
137 | |
138 @pending_deprecation("use logger.log_level = #") | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
139 def setLogLevel(self, log_level): |
18 | 140 self.log_level = log_level |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
141 |
18 | 142 @pending_deprecation("use logger.log_level") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
143 def getLogLevel(self): |
18 | 144 return self.log_level |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
145 |
18 | 146 @pending_deprecation("use logger.log_name = bla") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
147 def setLogName(self, log_name): |
18 | 148 self.log_name = log_name |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
149 |
18 | 150 @pending_deprecation("use logger.log_name") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
151 def getLogName(self): |
18 | 152 return self.log_name |
153 | |
154 @pending_deprecation("use logger.log_to_console = True/False") | |
155 def setLogToConsol(self, true_or_false): | |
156 self.log_to_consol = true_or_false | |
157 | |
158 @pending_deprecation("use logger.log_to_console") | |
159 def getLogToConsol(self): | |
160 return self.log_to_consol | |
161 | |
162 """ | |
163 Property Methods | |
164 """ | |
165 def _get_log_level(self): | |
166 return self._log_level | |
167 def _set_log_level(self, log_level): | |
168 if not isinstance(log_level, int) or log_level < 1 or log_level > 31: | |
169 raise TypeError("The loggers level must be an int between 1 and 31") | |
170 | |
171 self._log_level = log_level | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
172 |
18 | 173 def _get_log_name(self): |
174 return self._log_name | |
175 def _set_log_name(self, name): | |
176 if not os.access(os.path.abspath(os.path.dirname(name)), os.W_OK): | |
177 raise IOError("Could not write to the specified location") | |
178 | |
179 self._log_name = name | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
180 |
18 | 181 def _get_log_to_console(self): |
182 return self._log_to_console | |
183 def _set_log_to_console(self, true_or_false): | |
184 if not isinstance(true_or_false, bool): | |
185 raise TypeError("log_to_console must be a boolean value") | |
186 | |
187 self._log_to_console = true_or_false | |
188 | |
189 log_level = property(_get_log_level, _set_log_level) | |
190 log_name = property(_get_log_name, _set_log_name) | |
191 log_to_console = property(_get_log_to_console, _set_log_to_console) | |
192 | |
193 logger = orpgLog(dir_struct.get("user") + "runlogs/") | |
194 crash = sys.excepthook = Crash |