{
    "mode": "perldoc",
    "parameter": "Log::Any::Test",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Log%3A%3AAny%3A%3ATest/json",
    "generated": "2026-06-11T23:32:57Z",
    "synopsis": "use Test::More;\nuse Log::Any::Test;    # should appear before 'use Log::Any'!\nuse Log::Any qw($log);\n# ...\n# call something that logs using Log::Any\n# ...\n# now test to make sure you logged the right things\n$log->containsok(qr/good log message/, \"good message was logged\");\n$log->doesnotcontainok(qr/unexpected log message/, \"unexpected message was not logged\");\n$log->emptyok(\"no more logs\");\n# or\nmy $msgs = $log->msgs;\ncmpdeeply($msgs, [{message => 'msg1', level => 'debug'}, ...]);",
    "sections": {
        "NAME": {
            "content": "Log::Any::Test - Test what you're logging with Log::Any\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 1.710\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Test::More;\nuse Log::Any::Test;    # should appear before 'use Log::Any'!\nuse Log::Any qw($log);\n\n# ...\n# call something that logs using Log::Any\n# ...\n\n# now test to make sure you logged the right things\n\n$log->containsok(qr/good log message/, \"good message was logged\");\n$log->doesnotcontainok(qr/unexpected log message/, \"unexpected message was not logged\");\n$log->emptyok(\"no more logs\");\n\n# or\n\nmy $msgs = $log->msgs;\ncmpdeeply($msgs, [{message => 'msg1', level => 'debug'}, ...]);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Log::Any::Test\" is a simple module that allows you to test what has been logged with Log::Any.\nMost of its API and implementation have been taken from Log::Any::Dispatch.\n\nUsing \"Log::Any::Test\" signals \"Log::Any\" to send all subsequent log messages to a single global\nin-memory buffer and to make the log proxy provide a number of testing functions. To use it,\nload \"Log::Any::Test\" before anything that loads \"Log::Any\". To actually use the test methods,\nyou need to load \"Log::Any\" and get a log object from it, as shown in the \"SYNOPSIS\".\n",
            "subsections": []
        },
        "METHODS": {
            "content": "The testname is optional in the *ok methods; a reasonable default will be provided.\n\nmsgs ()\nReturns the current contents of the global log buffer as an array reference, where each\nelement is a hash containing a *category*, *level*, and *message* key. e.g.\n\n{\ncategory => 'Foo',\nlevel => 'error',\nmessage => 'this is an error'\n},\n{\ncategory => 'Bar::Baz',\nlevel => 'debug',\nmessage => 'this is a debug'\n}\n\ncontainsok ($regex[, $testname])\nTests that a message in the log buffer matches *$regex*. On success, the message is\n*removed* from the log buffer (but any other matches are left untouched).\n\ndoesnotcontainok ($regex[, $testname])\nTests that no message in the log buffer matches *$regex*.\n\ncategorycontainsok ($category, $regex[, $testname])\nTests that a message in the log buffer from a specific category matches *$regex*. On\nsuccess, the message is *removed* from the log buffer (but any other matches are left\nuntouched).\n\ncategorydoesnotcontainok ($category, $regex[, $testname])\nTests that no message from a specific category in the log buffer matches *$regex*.\n\nemptyok ([$testname])\nTests that there is no log buffer left. On failure, the log buffer is cleared to limit\nfurther cascading failures.\n\ncontainsonlyok ($regex[, $testname])\nTests that there is a single message in the log buffer and it matches *$regex*. On success,\nthe message is removed.\n\nclear ()\nClears the log buffer.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Log::Any, Test::Log::Dispatch\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   Jonathan Swartz <swartz@pobox.com>\n\n*   David Golden <dagolden@cpan.org>\n\n*   Doug Bell <preaction@cpan.org>\n\n*   Daniel Pittman <daniel@rimspace.net>\n\n*   Stephen Thirlwall <sdt@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2017 by Jonathan Swartz, David Golden, and Doug Bell.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "Log::Any::Test - Test what you're logging with Log::Any",
    "flags": [],
    "examples": [],
    "see_also": []
}