{"id":26246353,"url":"https://github.com/pwall567/log-front-test","last_synced_at":"2025-08-25T00:43:34.089Z","repository":{"id":280671116,"uuid":"937575622","full_name":"pwall567/log-front-test","owner":"pwall567","description":"Test functions for log-front logging library","archived":false,"fork":false,"pushed_at":"2025-03-13T13:17:24.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T08:56:25.019Z","etag":null,"topics":["java","library","logging","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwall567.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-23T12:03:16.000Z","updated_at":"2025-03-13T13:17:29.000Z","dependencies_parsed_at":"2025-03-04T18:03:17.739Z","dependency_job_id":"5a7656ed-5c80-49cb-a4cf-37c9e54fbad0","html_url":"https://github.com/pwall567/log-front-test","commit_stats":null,"previous_names":["pwall567/log-front-test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pwall567/log-front-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Flog-front-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Flog-front-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Flog-front-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Flog-front-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwall567","download_url":"https://codeload.github.com/pwall567/log-front-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Flog-front-test/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269351910,"owners_count":24402678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","library","logging","unit-testing"],"created_at":"2025-03-13T13:18:16.212Z","updated_at":"2025-08-08T02:07:51.251Z","avatar_url":"https://github.com/pwall567.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# log-front-test\n\n[![Build Status](https://github.com/pwall567/log-front-test/actions/workflows/build.yml/badge.svg)](https://github.com/pwall567/log-front-test/actions/workflows/build.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Maven Central](https://img.shields.io/maven-central/v/io.jstuff/log-front-test?label=Maven%20Central)](https://central.sonatype.com/artifact/io.jstuff/log-front-test)\n\nTesting functions for the [`log-front`](https://github.com/pwall567/log-front) logging library.\n\n## Background\n\nWhen testing an application that uses logging, a common requirement is to confirm that logging messages were output as\nexpected.\nThis library provides a simple mechanism for testing log output from applications that use the\n[`log-front`](https://github.com/pwall567/log-front) logging library.\n\n## Quick Start\n\nThe `LogList` class stores a list of all or selected logging messages output using `log-front`.\nFor example:\n```java\n        try (LogList logList = new LogList()) {\n            Logger log = Log.getLogger(\"xxx\");\n            // code that outputs log message to \"log\"\n            assertTrue(logList.hasInfo(\"Account created\"));\n        }\n```\n\n`LogList` makes use of the `LogListener` mechanism in `log-front`.\nBecause `LogListener` implements `AutoCloseable`, the easiest way of using it is within a try-with-resources block; that\nway the `LogList` will exist (and be supplied with log events) only for the duration of the test code.\n\n## Reference\n\n### `LogList`\n\nThe simplest form of `LogList` intercepts log events from all `Logger` instances:\n```java\n        LogList logList = new LogList();\n```\n\nBut sometimes it can be preferable to intercept log events for a selected set of `Logger`s; perhaps just one.\nA single `Logger` may be identified by name:\n```java\n        LogList logList = new LogList(\"xxx\");\n```\nOr by class:\n```java\n        LogList logList = new LogList(AccountsService.class);\n```\nOr for more complex cases, a [`StringMatcher`](https://github.com/pwall567/string-matcher) may be supplied:\n```java\n        LogList logList = new LogList(StringMatcher.wildcard(\"Accounts*\"));\n```\n\nThe `LogList` implements `List\u003cLogItem\u003e` (with all modifying operations returning `UnsupportedOperationException`), so\nit is possible to iterate through the list to locate a particular item.\nBut the more convenient way of examining the log output is to use one of the `hasXxxx()` functions:\n\n| Name                 | Argument | Returns `true` if the list contains...                           |\n|----------------------|----------|------------------------------------------------------------------|\n| `hasTrace`           | `Object` | ...a TRACE event with the specified message object               |\n| `hasDebug`           | `Object` | ...a DEBUG event with the specified message object               |\n| `hasInfo`            | `Object` | ...an INFO event with the specified message object               |\n| `hasWarn`            | `Object` | ...a WARN event with the specified message object                |\n| `hasError`           | `Object` | ...an ERROR event with the specified message object              |\n| `hasTraceContaining` | `String` | ...a TRACE event with a message containing the specified string  |\n| `hasDebugContaining` | `String` | ...a DEBUG event with a message containing the specified string  |\n| `hasInfoContaining`  | `String` | ...an INFO event with a message containing the specified string  |\n| `hasWarnContaining`  | `String` | ...a WARN event with a message containing the specified string   |\n| `hasErrorContaining` | `String` | ...an ERROR event with a message containing the specified string |\n\nThe `hasXxxx()` functions perform an exact match on the message object, but it is often simpler to compare just a\nsubstring of the message.\nThe `hasXxxxContaining()` functions perform this task.\n\n### `LogItem`\n\nFor those needing to perform more detailed checks on the log entries, the `LogList` stores log events as `LogItem`s,\nwhich contain the following:\n\n| Name        | Type        | Description                                           |\n|-------------|-------------|-------------------------------------------------------|\n| `time`      | `long`      | the time in milliseconds from the standard epoch      |\n| `name`      | `String`    | the `Logger` name                                     |\n| `level`     | `Level`     | the level of the logging event                        |\n| `message`   | `Object`    | the log message                                       |\n| `throwable` | `Throwable` | the `Throwable` associated with the log event, if any |\n\nAll of the logging functions take a message in the form of an `Object`; this allows an alternative means of lazy\ncreation of the message string (using the `toString()` on the object) \u0026ndash; for example, supplying a JSON object as\nthe message.\nThe `Object` form is provided in the `LogItem`, allowing the consumer of the `LogItem` to take advantage of any inherent\nstructure in the message.\n\nA convenience method gets the string form of the message (`null` will be returned as an empty string):\n\n- `getMessageString()`\n\nIn addition to the usual `toString()` method, `LogItem` has three overloaded versions:\n\n- `toString(char separator)`\n- `toString(ZoneId zoneId)`\n- `toString(char separator, ZoneId zoneId)`\n\nThe `toString()` is intended mainly for debugging, and these additional functions allow the separator (the default is\nspace) and the `ZoneId` to be used when formatting the time (the default is the current default time zone) to be\nspecified.\n\n## Dependency Specification\n\nThe latest version of the library is 6.2 (the version number of this library matches the version of `log-front` to which\nit relates), and it may be obtained from the Maven Central repository.\n(The following dependency declarations assume that the library will be included for test purposes; this is expected to\nbe its principal use.)\n\n### Maven\n```xml\n    \u003cdependency\u003e\n      \u003cgroupId\u003eio.jstuff\u003c/groupId\u003e\n      \u003cartifactId\u003elog-front-test\u003c/artifactId\u003e\n      \u003cversion\u003e6.2\u003c/version\u003e\n      \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n```\n### Gradle\n```groovy\n    testImplementation 'io.jstuff:log-front-test:6.2'\n```\n### Gradle (kts)\n```kotlin\n    testImplementation(\"io.jstuff:log-front-test:6.2\")\n```\n\nPeter Wall\n\n2025-03-13\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwall567%2Flog-front-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwall567%2Flog-front-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwall567%2Flog-front-test/lists"}