Hamid R. Parsaei

16 papers C 1Journal 13Unranked 2
YearRankTypeTitle / Venue / Authors
2026 J jnl
Neurocomputing
Ning Wang, Hamid R. Parsaei, Yali Ren
2021 J jnl
Symmetry
Mohammad Reza Davahli, Waldemar Karwowski, Krzysztof Fiok, Thomas T. H. Wan, Hamid R. Parsaei
2020 conf
AHFE (11)
Albertus Retnanto, Hamid R. Parsaei, Boback Parsaei
2018 J jnl
Ann. Oper. Res.
Gino J. Lim, Jaeyoung Cho, Selim Bora, Taofeek Biobaku, Hamid R. Parsaei
2017 J jnl
IEEE Trans. Learn. Technol.
Ning Wang, Xuemin Chen, Qianlong Lan, Gangbing Song, Hamid R. Parsaei, Siu-Chun Ho
2017 J jnl
IEEE Trans. Ind. Electron.
Ning Wang, Xuemin Chen, Gangbing Song, Qianlong Lan, Hamid R. Parsaei
2015 J jnl
Int. J. Online Eng.
Ning Wang, Xuemin Chen, Gangbing Song, Hamid R. Parsaei
2015 J jnl
Int. J. Online Eng.
Ning Wang, Xuemin Chen, Gangbing Song, Hamid R. Parsaei
2015 J jnl
Int. J. Online Eng.
Ning Wang, Xuemin Chen, Gangbing Song, Hamid R. Parsaei
2014 C conf
ICORES
Selim Bora, Endre Boros, Lei Lei, W. Art Chaovalitwongse, Gino J. Lim, Hamid R. Parsaei
2014 conf
ICORES (Selected Papers)
Selim Bora, Endre Boros, Lei Lei, W. Art Chaovalitwongse, Gino J. Lim, Hamid R. Parsaei
2008 J jnl
Int. J. Comput. Appl. Technol.
Ibrahim H. Garbie, Hamid R. Parsaei, Herman R. Leep
2000 J jnl
Int. J. Manuf. Technol. Manag.
Yung-Nien Yang, Hamid R. Parsaei, Herman R. Leep, Kosin Chuengsatiansup
1997 J jnl
Intell. Autom. Soft Comput.
Hamid R. Parsaei, Herman R. Leep
1997 J jnl
Intell. Autom. Soft Comput.
Jian Dong, Hamid R. Parsaei, Herman R. Leep
1994 J jnl
J. Intell. Manuf.
Munish Agarwal, Ali K. Kamrani, Hamid R. Parsaei
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