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

Introduce luatest.log helper #326

Closed
locker opened this issue Sep 8, 2023 · 0 comments · Fixed by #346
Closed

Introduce luatest.log helper #326

locker opened this issue Sep 8, 2023 · 0 comments · Fixed by #346
Assignees
Labels
feature A new functionality

Comments

@locker
Copy link
Member

locker commented Sep 8, 2023

The helper can be as simple as require('log').info(...), but it should specify the file and line of the log.

Why is it better that using require('log') directly? Because:

  • You don't need to require any extra modules, which makes the test more concise.
  • It provides a canonical way of logging within a test.

Adding logging to tests is useful because it can help figure out what went wrong in case of failure.

@locker locker added the feature A new functionality label Sep 8, 2023
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Dec 21, 2023
You can use `t.log` for logging. This is convenient in case of doping in
several places at the same time:

    t.log('foo log outside test')
    g.test_foo = function()
        t.log('some log inside test')
        g.server:exec(function() t.log('hi!') end)
    end

Closes tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Dec 28, 2023
You can use `t.log` for logging. This is convenient in case of doping in
several places at the same time:

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

    I> outside
    I> inside
    I> hi!

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

    t.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
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Dec 28, 2023
You can use `t.log` for logging. This is convenient in case of doping in
several places at the same time:

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

    I> outside
    I> inside
    I> hi!

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

    t.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
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Dec 28, 2023
You can use `t.log` for logging. This is convenient in case of doping in
several places at the same time:

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

    I> outside
    I> inside
    I> hi!

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

    t.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
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Jan 24, 2024
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 pushed a commit that referenced this issue Jan 24, 2024
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 added a commit to ochaplashkin/luatest that referenced this issue Feb 5, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Feb 5, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Feb 5, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Feb 5, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Feb 5, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Mar 5, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Mar 15, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Mar 15, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Mar 15, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Mar 15, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest.log')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ochaplashkin added a commit to ochaplashkin/luatest that referenced this issue Mar 18, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows tarantool#326
ylobankov pushed a commit that referenced this issue Mar 18, 2024
We improved `luatest.log` module for convenient logging and refactored
it:

    local t = require('luatest')
    t.log('Info log: %s', 'foo')
    t.log.warn('Warn log from %s', 'foo')

The following functions of the `luatest.log` module are presented:

    t.log.error(msg[, args])
    t.log.warn(msg[, args])
    t.log.info(msg[, args])
    t.log.verbose(msg[, args])
    t.log.debug(msg[, args])

    t.log() - syntax sugar for t.log.info(...)

Follows #326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants