mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-10-31 23:57:22 +01:00 
			
		
		
		
	Added optional line wrapping to logs.
This commit is contained in:
		
							parent
							
								
									2bbfc6f67a
								
							
						
					
					
						commit
						44e1098430
					
				| @ -1,3 +1,6 @@ | ||||
| 	* Added supybot.log.stdout.wrap, to allow optional (defaulting to | ||||
| 	True) wrapping of stdout logs. | ||||
| 	 | ||||
| 	* Added supybot.databases.plugins.channelSpecific, a channel | ||||
| 	value that determines whether the database used for channel-based | ||||
| 	plugins will be a channel-specific database or a global database. | ||||
|  | ||||
							
								
								
									
										14
									
								
								src/log.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/log.py
									
									
									
									
									
								
							| @ -40,6 +40,7 @@ import types | ||||
| import atexit | ||||
| import logging | ||||
| import operator | ||||
| import textwrap | ||||
| import traceback | ||||
| 
 | ||||
| import supybot.ansi as ansi | ||||
| @ -85,6 +86,15 @@ class StdoutStreamHandler(logging.StreamHandler): | ||||
|         finally: | ||||
|             logging._releaseLock() | ||||
| 
 | ||||
|     def format(self, record): | ||||
|         s = logging.StreamHandler.format(self, record) | ||||
|         if record.levelname != 'ERROR' and conf.supybot.log.stdout.wrap(): | ||||
|             # We check for ERROR there because otherwise, tracebacks (which are | ||||
|             # already wrapped by Python itself) wrap oddly. | ||||
|             prefixLen = len(record.name) + 2 # ": " | ||||
|             s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen) | ||||
|         return s | ||||
| 
 | ||||
|     def emit(self, record): | ||||
|         if conf.supybot.log.stdout() and not conf.daemonized: | ||||
|             try: | ||||
| @ -279,6 +289,10 @@ conf.registerGlobalValue(conf.supybot.log.stdout, 'colorized', | ||||
|     BooleanRequiredFalseOnWindows(False, """Determines whether the bot's logs | ||||
|     to stdout (if enabled) will be colorized with ANSI color.""")) | ||||
| 
 | ||||
| conf.registerGlobalValue(conf.supybot.log.stdout, 'wrap', | ||||
|     registry.Boolean(True, """Determines whether the bot will wrap its logs | ||||
|     when they're output to stdout.""")) | ||||
| 
 | ||||
| conf.registerGlobalValue(conf.supybot.log, 'timestampFormat', | ||||
|     registry.String('[%d-%b-%Y %H:%M:%S]', """Determines the format string for | ||||
|     timestamps in logfiles.  Refer to the Python documentation for the time | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jeremy Fincher
						Jeremy Fincher