Pre-commit discussion #126
                  
                    
                      Nubuki-all
                    
                  
                
                  started this conversation in
                Ideas
              
            Replies: 2 comments
-
| 
         This Enum is a bit stifling since some clients actually allow specifying the amount of selectable options Lines 371 to 381 in fd805a6 I'd revert the build_poll function to accepting an interger  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| 
         @krypton-byte import ctypes
import logging
from ..proto.Neonize_pb2 import LogEntry
try:
    from colorlog import ColoredFormatter
except Exception:
    ColoredFormatter = None
log = logging.getLogger(__name__)
if ColoredFormatter:
    formatter = ColoredFormatter(
        "%(asctime)s.%(msecs)03d %(log_color)s[%(name)s %(levelname)s] - %(message)s%(reset)s",
        datefmt="%H:%M:%S",
        log_colors={
            "INFO": "cyan",
            "WARNING": "yellow",
            "ERROR": "red",
            "CRITICAL": "bold_red",
        },
    )
    stream_handler = logging.StreamHandler()
    stream_handler.setFormatter(formatter)
else:
    stream_handler = logging.StreamHandler()
logging.basicConfig(
    format="%(asctime)s.%(msecs)03d [%(name)s %(levelname)s] - %(message)s",
    datefmt="%H:%M:%S",
    level=logging.INFO,
    handlers=[stream_handler],
)
clientlogger = logging.getLogger("whatsmeow.Client")
dblogger = logging.getLogger("Whatsmeow.Database")
def log_whatsmeow(binary: int, size: int):
    log_msg = LogEntry.FromString(ctypes.string_at(binary, size))
    if log_msg.Name == "Client":
        log = clientlogger
    elif log_msg.Name == "Database":
        log = dblogger
    else:
        log = logging.getLogger(f"whatsmeow.{log_msg.Name}")
    getattr(log, log_msg.Level.lower())(log_msg.Message)I was thinking that with this,   | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Discussion to iron out some kinks before sending a pull request.
Beta Was this translation helpful? Give feedback.
All reactions