J. W. Guan

20 papers A* 2A 1B 1C 2Journal 8Unranked 4
YearRankTypeTitle / Venue / Authors
2005 ch.
Intelligent Data Mining
J. W. Guan, David A. Bell, Dayou Liu
2005 ch.
Intelligent Data Mining
David A. Bell, J. W. Guan, Dayou Liu
2005 J jnl
IEEE Trans. Knowl. Data Eng.
David A. Bell, J. W. Guan, Yaxin Bi
2004 conf
Rough Sets and Current Trends in Computing
J. W. Guan, David A. Bell, Dayou Liu
2004 J jnl
Fundam. Informaticae
J. W. Guan, Dayou Liu, David A. Bell
2003 conf
RSFDGrC
David A. Bell, J. W. Guan
2003 A* conf
ICDM
J. W. Guan, David A. Bell, Dayou Liu
2001 J jnl
Inf. Sci.
J. W. Guan, David A. Bell, Z. Guan
2000 conf
Rough Sets and Current Trends in Computing
J. W. Guan, David A. Bell
1999 conf
ESCQARU
J. W. Guan, David A. Bell
1998 J jnl
J. Am. Soc. Inf. Sci.
David A. Bell, J. W. Guan
1998 J jnl
Artif. Intell.
J. W. Guan, David A. Bell
1997 J jnl
Inf. Sci.
J. W. Guan, David A. Bell
1997 J jnl
Inf. Sci.
J. W. Guan, Z. Guan, David A. Bell
1996 J jnl
Data Knowl. Eng.
David A. Bell, J. W. Guan, Suk Kyoon Lee
1994 B conf
ICTAI
J. W. Guan, Z. Guan, David A. Bell
1994 C conf
IEA/AIE
J. W. Guan, Z. Guan, David A. Bell
1993 A conf
UAI
J. W. Guan, David A. Bell
1993 A* conf
IJCAI
J. W. Guan, David A. Bell
1993 C conf
DEXA
J. W. Guan, David A. Bell
redb/logging_utils.py
← Index redb/logging_utils.py python
"""
Logging utilities and shared enums for REDB.

Contains the ImportResult enum, log formatters, and logger setup functions
used across the ingestor pipeline.
"""
import logging
from logging.handlers import QueueHandler
import os
from enum import Enum


class ImportResult(Enum):
    CORRECTLY = 0
    PARTIALLY = 1
    FAILED = 2
    PENDING = 3
    SKIPPED = 4


class FileNameFormatter(logging.Formatter):
    def format(self, record):
        record.filenameinfo = getattr(record, "filenameinfo", "unknown")
        return super().format(record)


def setup_logger(log_queue, filename):
    logger = logging.getLogger(filename)
    if not logger.handlers:
        if os.getenv("SERVER_ENV") == "prod":
            logger.setLevel(logging.INFO)
        else:
            logger.setLevel(logging.DEBUG)
        handler = QueueHandler(log_queue)
        logger.addHandler(handler)
        logger.propagate = False  # Prevent propagation to parent loggers
    return logger


def logger_thread(log_queue, log_file):
    handler = logging.FileHandler(log_file)
    formatter = FileNameFormatter(
        "%(asctime)s - %(filenameinfo)s - %(levelname)s - %(message)s"
    )
    handler.setFormatter(formatter)

    while True:
        try:
            record = log_queue.get()
            if record is None:
                break
            # Format and write the log record
            message = formatter.format(record)
            handler.stream.write(message + "\n")
            handler.stream.flush()
        except Exception:
            import traceback
            import sys

            print("[ERR] Error in logger thread:", file=sys.stderr)
            traceback.print_exc(file=sys.stderr)


def setup_direct_logger(log_file, filename, pid=None):
    """Setup a logger that writes directly to the log file without using a queue."""
    # Create a unique logger name using the process ID
    logger_name = f"{filename}_{pid}" if pid else filename
    logger = logging.getLogger(logger_name)

    if not logger.handlers:
        handler = logging.FileHandler(log_file)
        formatter = logging.Formatter("%(asctime)s - %(filenameinfo)s - %(levelname)s - %(message)s")
        handler.setFormatter(formatter)
        logger.addHandler(handler)

        if os.getenv("SERVER_ENV") == "prod":
            logger.setLevel(logging.INFO)
        else:
            logger.setLevel(logging.DEBUG)

    # Add filename info to the logger's extra info
    extra = {"filenameinfo": filename}
    logger = logging.LoggerAdapter(logger, extra)

    return logger