Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax sugar for more convenient logging #346

Merged

Conversation

ochaplashkin
Copy link
Contributor

@ochaplashkin ochaplashkin commented Dec 21, 2023

You can use luatest.log for logging. This is convenient in case of debugging in several places at the same time:

    local luatest = require('luatest')
    
    luatest.log('outside')
    g.test_foo = function()
        luatest.log('inside')
        g.server:exec(function() luatest.log('hi!') end)
    end

    I> outside
    I> inside
    I> hi!

The pretty conversion of arguments of any type will be performed automatically:

    luatest.log('My structure is %s', {a = 1, b = 2, c = {cc = 1}})
    I> My structure is {a = 1, b = 2, c = {cc = 1}}

Closes #326

@ochaplashkin ochaplashkin marked this pull request as draft December 21, 2023 15:14
@ochaplashkin ochaplashkin force-pushed the add-syntax-sugar-with-logging branch 3 times, most recently from 9a0328c to 9942619 Compare December 28, 2023 16:11
@ochaplashkin ochaplashkin marked this pull request as ready for review December 28, 2023 16:15
You can use `luatest.log` for logging. This is convenient in case of debugging
in several places at the same time:

    local luatest = require('luatest')

    luatest.log('outside')
    g.test_foo = function()
        luatest.log('inside')
        g.server:exec(function() luatest.log('hi!') end)
    end

    I> outside
    I> inside
    I> hi!

The pretty conversion of arguments of any type will be performed
automatically:

    luatest.log('My structure is %s', {a = 1, b = 2, c = {cc = 1}})
    I> My structure is {a = 1, b = 2, c = {cc = 1}}

Closes tarantool#326
@ylobankov ylobankov merged commit a005329 into tarantool:master Jan 24, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce luatest.log helper
2 participants