{"id":19640618,"url":"https://github.com/daniel-km/omeka-s-module-log","last_synced_at":"2025-07-22T09:34:09.539Z","repository":{"id":46098946,"uuid":"116640129","full_name":"Daniel-KM/Omeka-S-module-Log","owner":"Daniel-KM","description":"Module for Omeka S to monitor all logging messages and background jobs directly in the admin board.","archived":false,"fork":false,"pushed_at":"2025-07-02T11:14:56.000Z","size":487,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-02T12:26:47.711Z","etag":null,"topics":["logging","omeka-s","omeka-s-module","psr-3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Daniel-KM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2018-01-08T06:43:53.000Z","updated_at":"2025-07-02T11:15:01.000Z","dependencies_parsed_at":"2024-04-09T12:49:24.701Z","dependency_job_id":"8bbfc18f-91b5-4dde-8088-9639bb3bbbdc","html_url":"https://github.com/Daniel-KM/Omeka-S-module-Log","commit_stats":null,"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"purl":"pkg:github/Daniel-KM/Omeka-S-module-Log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-KM%2FOmeka-S-module-Log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-KM%2FOmeka-S-module-Log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-KM%2FOmeka-S-module-Log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-KM%2FOmeka-S-module-Log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Daniel-KM","download_url":"https://codeload.github.com/Daniel-KM/Omeka-S-module-Log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daniel-KM%2FOmeka-S-module-Log/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266465569,"owners_count":23933151,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["logging","omeka-s","omeka-s-module","psr-3"],"created_at":"2024-11-11T14:06:17.001Z","updated_at":"2025-07-22T09:34:09.527Z","avatar_url":"https://github.com/Daniel-KM.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Log (module for Omeka S)\n========================\n\n\u003e __New versions of this module and support for Omeka S version 3.0 and above\n\u003e are available on [GitLab], which seems to respect users and privacy better\n\u003e than the previous repository.__\n\n[Log] is a module for [Omeka S] that allows to monitor all logging messages and\nbackground jobs directly in the admin board, in syslog, or in cloud services via\nthird parties and make them easily checkable.\n\nFurthermore, additionnal logging destinations (alternative monitor, custom\nlogging…) and behaviors can be set just by providing their config, for example\nto send an email when a critical error occurs.\n\nThe logs are [PSR-3] compliant: they can managed by any other tool that respects\nthis standard (see below). They can be translated too.\n\nThe error monitoring service [Sentry] is now available as a separate module [Log Sentry].\nIt allows to log end user errors and to profile and to trace exceptions,\nallowing to find issues hard to reproduce quicker.\n\n\nInstallation\n------------\n\nThis module requires the module [Common], that should be installed first.\n\nSee general end user documentation for [installing a module].\n\n* From the zip\n\nDownload the last release [Log.zip] from the list of releases and uncompress it\nin the `modules` directory.\n\n* From the source and for development\n\nIf the module was installed from the source, rename the name of the folder of\nthe module to `Log`, go to the root module, and run:\n\n```sh\ncomposer install --no-dev\n```\n\nIf an issue appears after upgrade of Omeka, don’t forget to update the packages\nof Omeka: `rm -rf vendor \u0026\u0026 composer install --no-dev`.\n\n* Server with php 8.2 or greater\n\nTo support php 8.2 or greater, run this command first:\n\n```sh\ncomposer update\n```\n\n\nConfig\n------\n\nThe config is a pure Laminas log config: see the [Laminas Framework Log]\ndocumentation for the format. Only common settings are explained here.\n\nTo enable or disable an option or a writer, it is recommended to copy the wanted\nkeys inside your own `config/local.config.php`, so the maintenance will be\nsimpler.\n\nThe default config keeps the existing log mechanism inside the file `logs/application.log`,\nbut removes the logs of the jobs in the table `job` inside the Omeka database.\nThis second logs are useless with this module. Furthermore, the default log of\njobs is a big text field (4GB), so it may prevent to restore a database if there\nis a row is bigger than the param \"max_allowed_packet\" in the config of\nmariadb/mysql.\n\nThe logger allows to define one or more of writers (a file, a database, a cloud\nservice, syslog, etc.). All the writers are listed in `config['logger']['writers']`.\nWhen enable, a writer take its own config in the `config['logger']['options']['writers']`.\nSee the example in the [config of the module].\n\nNote: External logs (db, sentry, etc.) are not fully checked for performance\nreasons, and may fail silently, so their config should be checked separately.\n\n### Default logs\n\nAfter testing the module, if you want to disable double logging (stream for\ndirect logging and Omeka database for background jobs), add these keys in your\nown `config/local.config.php`:\n\n```php\n    'logger' =\u003e [\n        'log' =\u003e true,\n        'writers' =\u003e [\n            'stream' =\u003e false,\n            'job' =\u003e false,\n        ],\n    ],\n```\n\nInstead, you can set a different severity level for database logging and file\nlogging (this example shows the default levels):\n\n```php\n    'logger' =\u003e [\n        'log' =\u003e true,\n        'writers' =\u003e [\n            'stream' =\u003e false,\n            'job' =\u003e false,\n            'syslog' =\u003e true,\n        ],\n        'options' =\u003e [\n            'writers' =\u003e [\n                'db' =\u003e [\n                    'options' =\u003e [\n                        'filters' =\u003e \\Laminas\\Log\\Logger::INFO,\n                    ],\n                ],\n                'stream' =\u003e [\n                    'options' =\u003e [\n                        'filters' =\u003e \\Laminas\\Log\\Logger::NOTICE,\n                    ],\n                ],\n                'syslog' =\u003e [\n                    'options' =\u003e [\n                        'filters' =\u003e \\Laminas\\Log\\Logger::ERR,\n                    ],\n                ],\n            ],\n        ],\n    ],\n```\n\n### Background job logs\n\nThe job logs are automatically saved in the database and manageable in the admin\ninterface.\n\nThe default job logging is still enabled by default in config. To disable it,\nset the key `['logger']['writers']['job']` to false in your own `config/local.config.php`:\n\n```php\n    'logger' =\u003e [\n        'writers' =\u003e [\n            'job' =\u003e false,\n        ],\n    ],\n```\n\n### Php errors and exceptions\n\nBy default, exceptions that are not managed by Omeka and php errors are logged\nonly in the file `php_errors.log` of the server. To enable them inside the\nlogger, add the options, at your choice:\n\n```php\n    'logger' =\u003e [\n        'options' =\u003e [\n            'exceptionhandler' =\u003e true,\n            'errorhandler' =\u003e true,\n            'fatal_error_shutdownfunction' =\u003e true,\n        ],\n    ],\n```\n\nNote that **this will disable the default error logging of php and debug tools**,\nso if you want to keep it, add a writer for it.\n\nFurthermore, they are managed automatically for background jobs.\n\n### External database\n\nThe logs can be saved in an external database. To config it, add a file\n`database-log.ini` beside the main `database.ini` of Omeka S, with its params,\nand the params of the table inside `config['logger']['options']['writers']['db']['options']`.\nWarning: for technical reasons, Omeka use `dbname` and `user`, but Laminas uses\n`database` and `username`:\n\n```ini\nusername = \"\"\npassword = \"\"\ndatabase = \"\"\nhost     = \"\"\n;port     =\n;unix_socket =\n;driver   =\n```\n\nExtended options are supported via keys `driverOptions[xxx]`, in particular\nwhen the ssl option is on:\n\n```ini\ndriverOptions[1014] = 0\ndriverOptions[1009] = \"/path/to/domain.certificate.cer\"\n```\n\nHere, `1014` is `PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT` and `1009` is `PDO::MYSQL_ATTR_SSL_CA`.\n\nNote that when the logs are logged externally, the admin interface cannot be\nused for now.\n\n### Additionnal logging\n\nOther logging can be added. Just add their config in your `['logger']['options']`\nand enable them under the key `['logger']['writers']`. See the [Laminas Framework Log]\ndocumentation for the format of the config.\n\n### Sentry\n\nInstall module [Log Sentry] and update the config.\n\n**Warning**: the free Sentry subscription plan is limited to 5000 errors or\nexceptions by month.\n\n### Delete old logs\n\nWhen the table is growing too much, it's time to clear them. It can be done with\na task of the module [Easy Admin] or via these SQL queries:\n\n```sql\n# To delete all messages lower or equal to info:\nDELETE FROM `log`\nWHERE `severity` \u003c= 6;\n\n# To delete only duplicate messages:\nDELETE FROM `log`\nWHERE `message` IN (select message from (SELECT message FROM log GROUP BY message ORDER BY COUNT(id) DESC limit 12) as s);\n```\n\nPSR-3 and logging\n-----------------\n\nWith [PSR-3], the message uses placeholders that are not in C-style of the\nfunction `sprintf` (`%s`, `%d`, etc.), but in moustache-style, identified with\n`{` and `}`, without spaces.\n\nThese features depend on the module [Common]. Only specific features from the\ncurrent module are presented here.\n\n### Logging extra data\n\nThe module adds three extra data to improve management of logs inside Omeka: the\ncurrent user, the job and a reference. The user and the job are automatically\nadded via the extra keys `userId` and `jobId`, that replace manually set keys.\nThe reference can be added as additional key `referenceId`. These keys are added\nautomatically in most of the cases, so you don't need to add them. If the\ncontext uses these keys as placeholders, they are mapped in the message, else\nthey are removed from the context.\n\n```php\n// PSR-3 logging with extra data.\n$this-\u003elogger()-\u003einfo(\n    'The {resource} #{id} has been updated by user #{userId}.', // @translate\n    ['resource' =\u003e 'item', 'id' =\u003e 43, 'referenceId' =\u003e 'curation']\n);\n// output in stream: The item #43 has been updated by user #1. {\"referenceId\":\"curation\"}\n// output in database: The item #43 has been updated by user #1.\n```\n\nIn this implementation, like the default Laminas stream logger, extra data that\nare not mappable are json encoded and appended to the end of the message via the\nkey `{extra}`. So this key should not be used in the context when there are\nnon-mapped keys.\n\n```php\n// PSR-3 logging with non-mappable extra data.\n$this-\u003elogger()-\u003einfo(\n    'The {resource} #{id} has been updated by user #{userId}.', // @translate\n    ['resource' =\u003e 'item', 'id' =\u003e 43, 'referenceId' =\u003e 'curation', 'pid' =\u003e 1234]\n);\n// output in stream: The item #43 has been updated by user #1. {\"pid\":1234,\"referenceId\"=\"curation\"}\n// output in database: The item #43 has been updated by user #1. {\"pid\":1234}\n```\n\nThe reference can be any short string. It may be a category or a unique\nidentifier. If there is a job, it may repeat or not the values available in the\njob settings and metadata.\n\nIt can be added at the beginning of the process to avoid to set it for each log.\nThis is the normal way to log messages:\n\n```php\n// PSR-3 logging with reference id (a random number if not set).\n$referenceIdProcessor = new \\Laminas\\Log\\Processor\\ReferenceId();\n$referenceIdProcessor-\u003esetReferenceId('bulk/import/27');\n$this-\u003elogger()-\u003eaddProcessor($referenceIdProcessor);\n$this-\u003elogger()-\u003einfo(\n    'The {resource} #{id} has been updated by user #{userId}.', // @translate\n    ['resource' =\u003e 'item', 'id' =\u003e 43]\n);\n// output in stream: The item #43 has been updated by user #1. {\"referenceId\":\"MyModule: my-process\"}\n// output in database: The item #43 has been updated by user #1.\n```\n\n\nTODO\n----\n\n- [ ] Use key \"psr_log\" instead of \"log\" (see https://docs.laminas.dev/laminas-log/service-manager/#psrloggerabstractadapterfactory).\n- [ ] Use the second entity manager in all cases.\n- [ ] Add an option to copy logs inside jobs when the module is uninstalled.\n- [ ] Fix incompatibility between authentication modules (Ldap, Cas, Shibboleth). The user id is currently disabled in such a case.\n- [ ] Replace laminas-db by doctrine and a second entity manager.\n- [x] Separate Sentry into another module? It will be cleaner, but heavier in fact because only two small checks are needed, not a full module process.\n- [ ] Improve display for messages like \"item #xxx\", \"media #yyy\", \"resources #zz1, #zz2\" with or without context.\n\n\nWarning\n-------\n\nUse it at your own risk.\n\nIt’s always recommended to backup your files and your databases and to check\nyour archives regularly so you can roll back if needed.\n\n\nTroubleshooting\n---------------\n\nSee online issues on the [module issues] page on GitLab.\n\n\nLicense\n-------\n\nThis module is published under the [CeCILL v2.1] license, compatible with\n[GNU/GPL] and approved by [FSF] and [OSI].\n\nThis software is governed by the CeCILL license under French law and abiding by\nthe rules of distribution of free software. You can use, modify and/ or\nredistribute the software under the terms of the CeCILL license as circulated by\nCEA, CNRS and INRIA at the following URL \"http://www.cecill.info\".\n\nAs a counterpart to the access to the source code and rights to copy, modify and\nredistribute granted by the license, users are provided only with a limited\nwarranty and the software’s author, the holder of the economic rights, and the\nsuccessive licensors have only limited liability.\n\nIn this respect, the user’s attention is drawn to the risks associated with\nloading, using, modifying and/or developing or reproducing the software by the\nuser in light of its specific status of free software, that may mean that it is\ncomplicated to manipulate, and that also therefore means that it is reserved for\ndevelopers and experienced professionals having in-depth computer knowledge.\nUsers are therefore encouraged to load and test the software’s suitability as\nregards their requirements in conditions enabling the security of their systems\nand/or data to be ensured and, more generally, to use and operate it in the same\nconditions as regards security.\n\nThe fact that you are presently reading this means that you have had knowledge\nof the CeCILL license and that you accept its terms.\n\n\nCopyright\n---------\n\n* Copyright Daniel Berthereau, 2017-2025 [Daniel-KM] on GitLab)\n\n\n[Log]: https://gitlab.com/Daniel-KM/Omeka-S-module-Log\n[Log Sentry]: https://gitlab.com/Daniel-KM/Omeka-S-module-LogSentry\n[Omeka S]: https://omeka.org/s\n[PSR-3]: http://www.php-fig.org/psr/psr-3\n[Common]: https://gitlab.com/Daniel-KM/Omeka-S-module-Common\n[installing a module]: https://omeka.org/s/docs/user-manual/modules/#installing-modules\n[Log.zip]: https://gitlab.com/Daniel-KM/Omeka-S-module-Log/-/releases\n[Laminas Framework Log]: https://docs.laminas.dev/laminas-log\n[config of the module]: https://gitlab.com/Daniel-KM/Omeka-S-module-Log/-/blob/master/config/module.config.php#L6-126\n[Sentry]: https://sentry.io\n[module issues]: https://gitlab.com/Daniel-KM/Omeka-S-module-Log/-/issues\n[CeCILL v2.1]: https://www.cecill.info/licences/Licence_CeCILL_V2.1-en.html\n[GNU/GPL]: https://www.gnu.org/licenses/gpl-3.0.html\n[FSF]: https://www.fsf.org\n[OSI]: http://opensource.org\n[GitLab]: https://gitlab.com/Daniel-KM\n[Daniel-KM]: https://gitlab.com/Daniel-KM \"Daniel Berthereau\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel-km%2Fomeka-s-module-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaniel-km%2Fomeka-s-module-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel-km%2Fomeka-s-module-log/lists"}