How to use the asciidoctor-opal-runtime.Opal.Logger function in asciidoctor-opal-runtime

To help you get started, we’ve selected a few asciidoctor-opal-runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asciidoctor / asciidoctor.js / packages / core / spec / node / asciidoctor.spec.js View on Github external
it('should use the built-in Logger', () => {
        const pipe = Opal.StringIO.$new()
        const logger = Opal.Logger.$new(pipe)
        const now = new Date()
        logger.$add(2, 'hello', 'asciidoctor')
        const message = pipe.$string()
        expect(message).to.contain('WARN -- asciidoctor: hello')
        expect(message).to.contain('W, [')
        const datetime = /W, \[([^\]]+)].*/g.exec(message)[1]
        const datetimeRegexp = new RegExp(/([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\.([0-9]{6})/)
        const result = datetimeRegexp.exec(datetime)
        const year = parseInt(result[1])
        const month = parseInt(result[2])
        const day = parseInt(result[3])
        const hours = parseInt(result[4])
        const minutes = parseInt(result[5])
        const seconds = parseInt(result[6])
        const nowYear = now.getFullYear()
        const nowMonth = now.getMonth()