Skip to content

Commit

Permalink
Merge pull request #6 from axonops/colorlog
Browse files Browse the repository at this point in the history
chore: freeze requirements and color logging
  • Loading branch information
millerjp authored Oct 28, 2024
2 parents 99df66e + 17a76af commit 3feedbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions axonops/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import logging
import sys
from colorlog import ColoredFormatter


def setup_logger(name='AxonOpsLogger', level=logging.INFO):
Expand All @@ -23,9 +24,19 @@ def setup_logger(name='AxonOpsLogger', level=logging.INFO):
# Create handlers
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(level)
# Define a colored formatter
formatter = ColoredFormatter(
'%(log_color)s%(asctime)s - %(name)s - %(levelname)s - %(funcName)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
log_colors={
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'bold_red',
}
)

# Create formatters and add them to handlers
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(funcName)s - %(message)s')
console_handler.setFormatter(formatter)

# Clear existing handlers, and add new ones
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
certifi==2024.8.30
charset-normalizer==3.4.0
cloudscraper==1.2.71
colorlog==6.8.2
idna==3.10
numpy==2.1.2
pandas==2.2.3
Expand All @@ -12,6 +13,7 @@ PyYAML==6.0.2
requests==2.32.3
requests-toolbelt==1.0.0
six==1.16.0
termcolor==2.3.0
tzdata==2024.2
urllib3==2.2.3
yaspin
yaspin==3.1.0

0 comments on commit 3feedbf

Please sign in to comment.