PK!;77 LICENSE.txtThe MIT License (MIT) Copyright (c) 2018 Almer Mendoza Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.PK!& README.md# Rainbow Bridge Logger A wrapper for the native logging module of Python. Take note that colors are taken from ANSI and may not work as expected with Windows system. ## Installation ```sh pip install rainbow-bridge-logger # or pip3 ``` ## Usage ```python from rainbow import RainbowLogger # __name__ will get the current context # but you can pass any text you want, for identification logger = RainbowLogger(__name__) logger.info('my info') logger.warning('my warn') logger.error('my error') logger.debug('my debug') ``` Which should output the following: ![Output for logger](/res/rainbow-logger-output.png) ### Options #### Unset time in logging ```python logger = RainbowLogger(no_time=False) ``` #### Custom naming ```python logger = RainbowLogger('my_logger') ``` ## Todo - [ ] Improve possible arguments to be passed - [x] Added no_time argument to remove timestamps - [ ] Add capability for custom formats and coloring - [ ] Improve pathing for module - [ ] Allow easy integration with other frameworks that uses logging - [ ] Enable with Windows (ANSI to Win32 color codes) - [x] Publish to pip to be usable anywhere - [x] Create installation section - [x] Improve README - [x] Create usage section ## Note Tested on both Python 2.7 and Python 3.6 ## Author - Almer T. Mendoza PK!ʢZlong-description.rst Rainbow Bridge Logger ================================= A wrapper for the native logging module of Python. .. code-block:: python from rainbow import RainbowLogger # __name__ will get the current context # but you can pass any text you want, for identification logger = RainbowLogger(__name__) logger.info('my info') logger.warning('my warn') logger.error('my error') logger.debug('my debug') PK!N܀rainbow/__init__.py__version__ = '0.4.0' try: from rainbow.rainbow import RainbowLogger except ImportError: from rainbow import RainbowLogger PK!~-Ƃ rainbow/rainbow.py""" :Author: Almer Mendoza :Since: 10/10/2018 """ _logging_module = None _is_no_color = False def _get_color(color=None): """Get color name from pre-defined color list""" if _is_no_color: return '' if color is None and not color: raise ValueError('Must have color code') colors = { 'PURPLE':'\033[96m', 'MAGENTA':'\033[95m', 'BLUE':'\033[94m', 'GREEN':'\033[92m', 'YELLOW':'\033[93m', 'RED':'\033[91m', 'DARKGRAY':'\033[90m', 'GREY':'\033[0m', 'WHITE':'\033[1m' } if color not in colors: raise KeyError('Use a proper color name: {}'.format(list(colors.keys()))) return colors[color] def _get_message(no_time=False): """Get message parts""" time = '{}%(asctime)s{}'.format(_get_color('DARKGRAY'), _get_color('GREY')) name = '{}%(name)-12s{}'.format(_get_color('PURPLE'), _get_color('GREY')) level = '%(levelname)-8s' message = '%(message)s' if no_time: return '{} {}\t{}'.format(name, level, message) return '{} {} {}\t{}'.format(time, name, level, message) def _set_level_format(level=None, color='WHITE'): """Set logging format based on level and color""" FORMAT = '{}{}{}' parsed_format = FORMAT.format( _get_color(color), _logging_module.getLevelName(level), _get_color('GREY') ) if level is not None: _logging_module.addLevelName(level, parsed_format) return True def RainbowLogger(name=None, no_time=False, no_color=False, new_logging=None, filepath=None, log_level=None, get_logging=False): """A customized logger built on top of Python's logging""" import logging global _logging_module global _is_no_color _is_no_color = no_color _logging_module = logging if new_logging is not None: _logging_module = new_logging _set_level_format(_logging_module.DEBUG, 'BLUE') _set_level_format(_logging_module.INFO, 'GREEN') _set_level_format(_logging_module.WARN, 'YELLOW') _set_level_format(_logging_module.ERROR, 'RED') _set_level_format(_logging_module.CRITICAL, 'MAGENTA') if name is None: logger = _logging_module else: logger = _logging_module.getLogger(name) handler = _logging_module.StreamHandler() final_message = _get_message(no_time) formatter = _logging_module.Formatter(final_message) handler.setFormatter(formatter) if name is None: _logging_module.basicConfig(format=final_message, level=log_level if log_level else _logging_module.DEBUG) else: logger.addHandler(handler) logger.setLevel(log_level if log_level else _logging_module.DEBUG) if filepath and name: handler = _logging_module.FileHandler(filepath) _is_no_color = True final_message = _get_message(no_time) formatter = _logging_module.Formatter(final_message) handler.setFormatter(formatter) logger.addHandler(handler) if get_logging: return _logging_module return logger def __init__(): return RainbowLogger PK!hf f res/rainbow-logger-output.pngPNG  IHDR6M.sBIT|dtEXtSoftwaregnome-screenshot>IDATxw|TUϝ3ɤW $@  uu-+e* vmQQwqWbYu]( !AB ɤɴ0Lޯ/_3gɹ3Csܯ8ZC!uB!ڋ6B!5B!D!B!z )lBkHa#B^C !BR!אF!6B!5B!DvIrY⮞z|"y]wA||V``Ҥf3C3f4!p(5M1K[l-cFDD0)׬iTrrsd2qq{#//Mc6?~0CTWWIbb6[ӁitOJ㹭yyOHͿtèUZi {Ҩyq+ƅG3;q>8?z~NN*>`h4vzM6Ğ={l;xv @ֲknG<~uG߽%#P^Ay+=mۍOgkz- ~h~Լ(} دA_%ʻQ,u~<=ْgmSڵ$詚,l\.{/`a@ Ixx;vpz8K.Ʉj% 0}0x@1  q:3:1Ur}N1K[lc *:khdz{FEшéS4M#~HIczݛSVVv8 RiHb L&V[:QӹPU#ҿ#1ټNwX1c|2sw1b$yyyq-^Ο1}F`4;?޳8\(*@qm~_n#`0g^%%QPP/,#*2g w{jkkxejwirx=(YY<=(7$??(^zqcƌaY̞3M;w "''~xZ-<':rZtzONf#88LJKKp8$!!@܈4[e:G`` Ç#<5>u:QC{v]"22ii<zLKKcXx)((s撖;9s=Em6PVV?CzNn4Mv{HLL@UU>ߘf>C  ?2͖山mp8ꗓ;bZY Jq^τdIYYCI)[Ӊ^gK@XJ72sp\4>gHgg{׽瓞i3f,W"]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qр#HLgtR1 :pM뎖{[꥞ug/+vSBѣ0Aܣ en47j;1)&q>Np?WmO!#ޒ-ޒ"NؕӋ#ō;ZI* ,xq|a֯=NnMUUX#GhdffL_c ]Iw'toI(#A9?X19[trvٶ@tT+oA6;fOIIc1^>|8N kXQ}TU壏l?`0x]uטBtG݉$[ҽ{ZkiEI`Kf2f?uɶZ ^cHkv̞=ҽ 獕+ kRznJJKlݗ{wIt EJ^bfB'ٖN (p<^ oSWwII EEE<#6ғE(h(D,v$[ҽ%44FDkJgD+ٶ3(q >ӊ^O*43J1CIkWTTU[noa #;;پM9|8 u^w71}4Ng}$[ҽtoI>Gtqީ.y$[ҽQҽSLVMALl|b G[yRo\v1EŢ|;?cp87,"=WΧ9͇)"rZBI{K{7ϭᨭ"c'W'>#˱\AN4g<S4p;강fʞMyz}{bg)vg=lP͛GtT'NyJ;\RŠ+>+^?sUgultΐ!CX,̒g}I{<It3YDZ:4}00cC$v9(K#fٵ:"h4pocU撿nc}vW٨z#Hw'toI-PM!qW-`fo~Hf Ӗ#) A]U1!%oj,E!=E{{R^~&J6Exdd$fSBtWE$[ҽ{*S@L:+[>aĕ?{M9PQ]F,T †'S{IO^ޥDEEItDEFb6PWW"$$QnEEa-8B!ItoI>{7A` =_/hZ,ӛNEQlhӊVEAo'+1PSΊNo`9Kb&]:=U㪳PYB')BọmW}pNo%au\zv3gzKO_-[=UBt%ItF$[ҽOrq3Ux:21?L{n}T3^=Yǽث[Q=@c-9㪫/Y@/Sa5{oZp8xu,,Y$3\wff&szJvv6/o3Y2_7Vn+HVh5IzRX*PUK.CzZB, Dҽ[Stzwt֯]=-!%+6$ݻz<j]]@I)BBҽBkHa#B^C !BR!אF!6B!5B!D!B!z )lBk?˜IENDB`PK!;771rainbow_bridge_logger-0.4.0.dist-info/LICENSE.txtThe MIT License (MIT) Copyright (c) 2018 Almer Mendoza Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.PK!H|n-WY+rainbow_bridge_logger-0.4.0.dist-info/WHEEL A н#Z;/" bFF]xzwK;<*mTֻ0*Ri.4Vm0[H, JPK!H-.rainbow_bridge_logger-0.4.0.dist-info/METADATASMo@ġ7mRd)PT$Pk'΂wnjuͯgP{;3+t*SN_+M6Xi&޲r sdx!䅸Q&pkJG̠aUȰ#~D@;kݞ,2*yΕU2LL/uiJk?0 #y:!I;2lQiBتuGubjC|NwRq))i_+0Lldz Ŏ4 0yK_?g%_Gfo ܞ` ^sVCd%慭 Ĩ?-ȅ KqU]678&j˦gge:񏌍4^07PK!;77 LICENSE.txtPK!& `README.mdPK!ʢZ long-description.rstPK!N܀ rainbow/__init__.pyPK!~-Ƃ 7 rainbow/rainbow.pyPK!hf f res/rainbow-logger-output.pngPK!;7718rainbow_bridge_logger-0.4.0.dist-info/LICENSE.txtPK!H|n-WY+=rainbow_bridge_logger-0.4.0.dist-info/WHEELPK!H-.=rainbow_bridge_logger-0.4.0.dist-info/METADATAPK!Hz ,@rainbow_bridge_logger-0.4.0.dist-info/RECORDPK =B