public void log(final DriverEventCode code, final DirectBuffer buffer, final int offset, final int length)
    {
        if (DriverComponentLogger.ENABLED_EVENTS.contains(code))
        {
            final int captureLength = captureLength(length);
            final int encodedLength = encodedLength(captureLength);

            final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
            final int index = ringBuffer.tryClaim(toEventCodeId(code), encodedLength);
            if (index > 0)
            {
                try
                {
                    encode((UnsafeBuffer)ringBuffer.buffer(), index, captureLength, length, buffer, offset);
                }
                finally
                {
                    ringBuffer.commit(index);
                }
            }
        }
    }
@Test
    void log()
    {
        final DriverEventCode eventCode = CMD_IN_TERMINATE_DRIVER;
        DriverComponentLogger.ENABLED_EVENTS.add(eventCode);
        final int recordOffset = align(13, ALIGNMENT);
        logBuffer.putLong(CAPACITY + TAIL_POSITION_OFFSET, recordOffset);
        final int length = 100;
        final int srcOffset = 20;
        buffer.setMemory(srcOffset, length, (byte)5);

        logger.log(eventCode, buffer, srcOffset, length);

        verifyLogHeader(logBuffer, recordOffset, toEventCodeId(eventCode), length, length);
        for (int i = 0; i < length; i++)
        {
            assertEquals(5, logBuffer.getByte(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH + i)));
        }
    }