Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  serialized_logging.py

  Sprache: Python
 

Anforderungen.py Begriffe der KonzeptbildungUnknown {[0] [0] [0]}Entwicklung

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import json
import logging

SERIALIZED_RECORD_PREFIX = "MOZLOG "


class SerializedRecordFormatter(logging.Formatter):
    """A logging.Formatter which produces serialized logging.LogRecords."""

    def format(self, record):
        s = json.dumps(record.__dict__)
        return SERIALIZED_RECORD_PREFIX + s


def output_serialized_records(logger):
    """Add a handler to the given logger to output serialized records to stderr."""
    handler = logging.StreamHandler()
    handler.setFormatter(SerializedRecordFormatter())
    logger.addHandler(handler)


def serialize_root_logger():
    """Configure the root logger to output serialized records."""
    output_serialized_records(logging.root)


def is_serialized_record(line):
    """Return whether the given line is a serialized log record."""
    return line.startswith(SERIALIZED_RECORD_PREFIX)


def read_serialized_record(line):
    """Read a serialized log record.

    Returns the logging.LogRecord, or None if a log record wasn't found.
    """
    if is_serialized_record(line):
        try:
            return logging.makeLogRecord(
                json.loads(line[len(SERIALIZED_RECORD_PREFIX) :])
            )
        except (json.JSONDecodeError, UnicodeDecodeError):
            # In case of malformed JSON data, we assume the record was not a
            # valid serialized log record.
            pass

    return None

¤ Dauer der Verarbeitung: 0.20 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002