{"id":19826251,"url":"https://github.com/aternosorg/codex","last_synced_at":"2025-05-01T14:31:07.539Z","repository":{"id":34159211,"uuid":"170808931","full_name":"aternosorg/codex","owner":"aternosorg","description":"PHP library to read, parse, print and analyse log files.","archived":false,"fork":false,"pushed_at":"2024-12-20T14:00:31.000Z","size":220,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T21:46:41.486Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/aternos/codex","language":"PHP","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/aternosorg.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":"2019-02-15T05:50:40.000Z","updated_at":"2024-12-13T13:41:33.000Z","dependencies_parsed_at":"2024-01-29T13:25:02.577Z","dependency_job_id":"f3be4d64-47aa-4159-b17a-66de35818432","html_url":"https://github.com/aternosorg/codex","commit_stats":{"total_commits":92,"total_committers":4,"mean_commits":23.0,"dds":0.2934782608695652,"last_synced_commit":"900a28c00285d5c97bcaf08b9407bb413fd7ac9f"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fcodex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fcodex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fcodex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fcodex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aternosorg","download_url":"https://codeload.github.com/aternosorg/codex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251889976,"owners_count":21660424,"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","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":[],"created_at":"2024-11-12T11:09:53.362Z","updated_at":"2025-05-01T14:31:07.170Z","avatar_url":"https://github.com/aternosorg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Codex\n\n### About\n\nCodex (*lat. roughly for \"log\"*) is a PHP library to read, parse, print and analyse log files to find problems and suggest possible\nsolutions. It was created mainly for Minecraft server logs but could be used for any other logs as well. This library provides a set\nup for a structured log parsing implementation and provides some useful basic implementation, mainly based on RegEx. Every part\nof this library can or even must be extended/overwritten while still following the interfaces, which ensure interoperability between\nthe different parts of this library.\n\n### Installation\n\n```\ncomposer require aternos/codex\n```\n\n## Usage\n\nThis is a short introduction to the idea of Codex, for some more examples check the [test](test) folder\nand/or read the [code](src).\n\n### Logfile\n\nA [`LogFile`](src/Log/File/LogFile.php) object implementing the [`LogFileInterface`](src/Log/File/LogFileInterface.php) object is required\nto start reading a log. There are currently three different log file classes in this library.\n\n```php\n\u003c?php\n\n$logFile = new \\Aternos\\Codex\\Log\\File\\StringLogFile(\"This is the log content\");\n$logFile = new \\Aternos\\Codex\\Log\\File\\PathLogFile(\"/path/to/log\");\n$logFile = new \\Aternos\\Codex\\Log\\File\\StreamLogFile(fopen(\"/path/to/log\", \"r\"));\n```\n\n### Log\n\nA [`Log`](src/Log/Log.php) object implementing the [`LogInterface`](src/Log/LogInterface.php) is the most important object\nfor the different operations. It represents the log content, which is split in [Entries](src/Log/EntryInterface.php) and [Lines](src/Log/LineInterface.php).\nAnd it offers quick access to the detection, parsing and analysing functions and can define which classes are used\nfor those functions. If you know which log type you have or just want to test the default [Log](src/Log/Log.php) class, you can\ndirectly create a new instance, otherwise you can use detection as described below.\n\n```php\n\u003c?php\n\n$log = new \\Aternos\\Codex\\Log\\Log();\n$log-\u003esetLogFile($logFile);\n```\n\n### Detection\n\nIf the log type (specifically the class name of the log type) is unknown you can use the [`Detective`](src/Detective/Detective.php) class\nto automatically detect the log type. The `Detective` class gets a list of possible log class names and executes\ntheir given [Detectors](src/Detective/DetectorInterface.php).\n\n```php\n\u003c?php\n\n$detective = new \\Aternos\\Codex\\Detective\\Detective();\n$detective-\u003eaddPossibleLogClass(\\Aternos\\Codex\\Log\\Log::class);\n$log = $detective-\u003edetect();\n```\n\nThe `detect()` function always returns a log object, if necessary it defaults to [`Log`](src/Log/Log.php).\n\n### Parsing\n\nParsing reads the entire log and creates the [`Entry`](src/Log/EntryInterface.php) and [`Line`](src/Log/LineInterface.php) objects which\nare parts of a [`Log`](src/Log/LogInterface.php) object. Different log types can use different parsers by overwriting the \n`LogInterface::getDefaultParser()` function or by passing a parser object to the parse function.\n\n```php\n\u003c?php\n\n$log-\u003eparse();\n```\n\n### Analysing\n\nAn analysis is performed by an [`Analyser`](src/Analyser/AnalyserInterface.php) on an [`AnalysableLog`](src/Log/AnalysableLogInterface.php) and returns\nan [`Analysis`](src/Analysis/AnalysisInterface.php) object containing various [`Insight`](src/Analysis/InsightInterface.php) objects, e.g. a [`Problem`](src/Analysis/ProblemInterface.php)\nor an [`Information`](src/Analysis/InformationInterface.php) object. Different log types can use different analysers by overwriting\nthe `AnalysableLogInterface::getDefaultAnalyser()` function or by passing an analyser object to the analyse function.\n\n```php\n\u003c?php\n\n$analysis = $log-\u003eanalyse();\n```\n\n### Printing\n\nThe entire [`Log`](src/Log/LogInterface.php) or just an [`Entry`](src/Log/EntryInterface.php) can be printed through a [`Printer`](src/Printer/PrinterInterface.php). The basic\n[`DefaultPrinter`](src/Printer/DefaultPrinter.php) only prints the plain content line by line. The [`ModifiableDefaultPrinter`](src/Printer/ModifiableDefaultPrinter.php)\nallows [`Modification`](src/Printer/ModificationInterface.php), e.g. to highlight certain characters/words.\n\n```php\n\u003c?php\n\n$printer = new \\Aternos\\Codex\\Printer\\DefaultPrinter();\n$printer-\u003esetLog($log);\n$printer-\u003eprint();\n\n$printer = new \\Aternos\\Codex\\Printer\\DefaultPrinter();\n$printer-\u003esetEntry($entry);\n$printer-\u003eprint();\n\n$printer = new \\Aternos\\Codex\\Printer\\ModifiableDefaultPrinter();\n$printer-\u003esetLog($log);\n$modification = new \\Aternos\\Codex\\Printer\\PatternModification();\n$modification-\u003esetPattern('/foo/');\n$modification-\u003esetReplacement('bar');\n$printer-\u003eaddModification($modification);\n$printer-\u003eprint();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternosorg%2Fcodex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faternosorg%2Fcodex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternosorg%2Fcodex/lists"}