const NormalizerFormatter = Jymfony.Component.Logger.Formatter.NormalizerFormatter;

/**
 * @memberOf Jymfony.Component.Logger.Formatter
 */
class JsonFormatter extends NormalizerFormatter {
    /**
     * Constructor.
     */
    __construct() {
        super.__construct(NormalizerFormatter.SIMPLE_DATE);
    }

    /**
     * @inheritDoc
     */
    _normalize(record, depth = 0) {
        if (isScalar(record)) {
            if (isNumber(record) && ! Number.isFinite(record)) {
                return (0 < record ? '' : '-') + 'INF';
            }

            if (isNaN(record)) {
                return 'NaN';
            }
        }

        if (isArray(record)) {
            return record.map(v => this._normalize(v, depth + 1));
        }

        if (isObjectLiteral(record)) {
            const normalized = {};
            let count = 0;
            for (const [ key, value ] of __jymfony.getEntries(record)) {
                if (1000 < ++count) {
                    normalized['...'] = 'Over 1000 entries. Aborting normalization...';
                    break;
                }

                normalized[key] = this._normalize(value, depth + 1);
            }

            return normalized;
        }

        if (record instanceof Date) {
            record = new DateTime(record);
        }

        if (record instanceof DateTime) {
            return this._formatDate(record);
        }

        if (isObject(record)) {
            if (record instanceof Error) {
                return this._normalizeError(record);
            }

            const reflClass = new ReflectionClass(record);
            let value;
            if (reflClass.hasMethod('toString')) {
                value = record.toString();
            } else {
                const encoded = JSON.stringify(record);
                value = JSON.parse(encoded);
            }

            return { [reflClass.name]: value };
        }

        return record;
    }
}

module.exports = JsonFormatter;

@@ -1,12 +1,66 @@
+const DateTime = Jymfony.Component.DateTime.DateTime;%0A
 const Normal
@@ -404,76 +404,159 @@
     
-_normalize(record, depth = 0) %7B%0A        if (isScalar(record)) %7B%0A    
+format(record) %7B%0A        return JSON.stringify(this._normalize(record));%0A    %7D%0A%0A    /**%0A     * @inheritDoc%0A     */%0A    _normalize(record, depth = 0) %7B%0A
     
@@ -583,12 +583,28 @@
 ord)
- && 
+) %7B%0A            if (
 ! Nu
@@ -719,21 +719,25 @@
 if (
-isNaN(record)
+record !== record
 ) %7B%0A

fix json formatter (format as string and NaN handling)