Multi-processing capable print-like logger for Python

Related tags

Logging MPLogger
Overview

MPLogger

Multi-processing capable print-like logger for Python

Requirements and Installation

Python 3.8+ is required

Pip

pip install mplogger

Manual

Poetry and (optionally) GNU Make are required.

  1. git clone https://github.com/ELTE-DH/webarticlecurator.git
  2. Run make

On Windows or without Make (after cloning the repository):

  1. poetry install --no-root
  2. poetry build
  3. poetry run pip install --upgrade dist/*.whl (the correct filename must be specified on Windows)

Usage

Single-process

from MLPlogger import Logger

# Initialize logger (default: STDERR only with INFO level)
logger = Logger(log_filename, logfile_mode, logfile_encoding, logfile_level, console_stream, console_level, console_format, file_format)

logger.log('INFO', 'First argument log level as string')
logger.log('WARNING', 'THIS IS A WARNING!', 'In multiple lines', 'just like print()', sep='\n')
logger.log('CRITICAL', 'Can also set line endings!', end='\r\n')

Multi-process

from itertools import repeat
from multiprocessing import Pool, Manager, current_process

from MLPlogger import Logger

def worker_process(par):
    state, lq = par
    retl = []
    for n in range(100):
        lq.log('WARNING', f'{current_process().name} message{state} {n}')
    lq.log('WARNING', f'{current_process().name} finished')
    return retl

log_obj = Logger('test.log', 'w')  # Apply all parameters for logger here!
log_obj.log('INFO', 'NORMAL LOG BEGIN')  # Normal logging
with Manager() as man:
    log_queue = man.Queue()
    with log_obj.init_mp_logging_context(log_queue) as mplogger, Pool() as p:
        # Here one can log parallel from all processes!
        return_queue = p.imap(worker_process, zip(range(10), repeat(mplogger)), chunksize=3)
        for _ in return_queue:
            pass
log_obj.log('INFO', 'NORMAL LOG END')  # Normal logging

Licence

This project is licensed under the terms of the GNU LGPL 3.0 license.

You might also like...
Fuzzy-logger - Fuzzy project is here Log all your pc's actions Simple and free to use Security of datas !
Fuzzy-logger - Fuzzy project is here Log all your pc's actions Simple and free to use Security of datas !

Fuzzy-logger - ➡️⭐ Fuzzy ⭐ project is here ! ➡️ Log all your pc's actions ! ➡️ Simple and free to use ➡️ Security of datas !

A watchdog and logger to Discord for hosting ScPrime servers.

ScpDog A watchdog and logger to Discord for hosting ScPrime servers. Designed to work on Linux servers. This is only capable of sending the logs from

Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate.

python-tabulate Pretty-print tabular data in Python, a library and a command-line utility. The main use cases of the library are: printing small table

A small utility to pretty-print Python tracebacks. ⛺
A small utility to pretty-print Python tracebacks. ⛺

TBVaccine TBVaccine is a utility that pretty-prints Python tracebacks. It automatically highlights lines you care about and deemphasizes lines you don

A very basic esp32-based logic analyzer capable of sampling digital signals at up to ~3.2MHz.
A very basic esp32-based logic analyzer capable of sampling digital signals at up to ~3.2MHz.

A very basic esp32-based logic analyzer capable of sampling digital signals at up to ~3.2MHz.

ScreenshotLogger works just like a keylogger but instead of capturing keystroke,it captures the screen, stores it or sends via email

ScreenshotLogger works just like a keylogger but instead of capturing keystroke,it captures the screen, stores it or sends via email. Scrapeasy is super easy to use and handles everything for you. Just specify what website you want to scrape and what media you want to receive back, and the rest is done for you.

Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"

Text progress bar library for Python. Travis status: Coverage: Install The package can be installed through pip (this is the recommended method): pip

Python logging made (stupidly) simple
Python logging made (stupidly) simple

Loguru is a library which aims to bring enjoyable logging in Python. Did you ever feel lazy about configuring a logger and used print() instead?... I

The new Python SDK for Sentry.io
The new Python SDK for Sentry.io

sentry-python - Sentry SDK for Python This is the next line of the Python SDK for Sentry, intended to replace the raven package on PyPI. from sentry_s

Comments
  • Fix package name in examples

    Fix package name in examples

    The package name on PyPI and in the installation instruction is mplogger but in the examples it is MLPlogger. It seems that the latter one is the typo.

    opened by sunarch 0
Owner
Eötvös Loránd University Department of Digital Humanities
National Laboratory for Digital Heritage
Eötvös Loránd University Department of Digital Humanities
Discord-Image-Logger - Discord Image Logger With Python

Discord-Image-Logger A exploit I found in discord. Working as of now. Explanatio

null 111 Dec 31, 2022
Json Formatter for the standard python logger

Overview This library is provided to allow standard python logging to output log data as json objects. With JSON we can make our logs more readable by

Zakaria Zajac 1.4k Jan 4, 2023
Json Formatter for the standard python logger

This library is provided to allow standard python logging to output log data as json objects. With JSON we can make our logs more readable by machines and we can stop writing custom parsers for syslog type records.

Zakaria Zajac 1k Jul 14, 2021
A simple, transparent, open-source key logger, written in Python, for tracking your own key-usage statistics.

A simple, transparent, open-source key logger, written in Python, for tracking your own key-usage statistics, originally intended for keyboard layout optimization.

Ga68 56 Jan 3, 2023
This is a key logger based in python which when executed records all the keystrokes of the system it has been executed on .

This is a key logger based in python which when executed records all the keystrokes of the system it has been executed on

Purbayan Majumder 0 Mar 28, 2022
Fancy console logger and wise assistant within your python projects

Fancy console logger and wise assistant within your python projects. Made to save tons of hours for common routines.

BoB 5 Apr 1, 2022
Ultimate Logger - A Discord bot that logs lots of events in a channel written in python

Ultimate Logger - A Discord bot that logs lots of events in a channel written in python

Luca 2 Mar 27, 2022
Token Logger with python

Oxy Token Stealer Features Grabs discord tokens Grabs chrome passwords Grabs edge passwords Nothing else, I don't feel like releasing full on malware

oxy 1 Feb 12, 2022
This open-source python3 script is a builder to the very popular token logger that is on my github that many people use.

Discord-Logger-Builder This open-source python3 script is a builder to the very popular token logger that is on my github that many people use. This i

Local 4 Nov 17, 2021
giving — the reactive logger

giving is a simple, magical library that lets you log or "give" arbitrary data throughout a program and then process it as an event stream.

Olivier Breuleux 0 May 24, 2022