Changing the code

Which files to open for the most common changes, how to run the tests, and the contribution rules.

Where to go in the Loghound code to change something, how to run the tests and a preview, and the rules every contribution follows.

01 · Where to go to change something
Add or change a scoring rule

src/Score/Signals.php (the evidence) and src/Score/Rules.php (weights, reasons); raise Rules::RULE_VERSION when weights change; tests in tests/test_scoring.php for the rule firing and not firing; docs/DETECTION.md.

Add a panel view

A controller in src/Panel/, registered in Layout::routes() and Layout::nav(); a module in public/assets/js/views/ imported by app.js; docs/PANEL.md.

Store a new field

The schema in solr/*/conf/schema.xml; fill it in Parser.php (hits) or bin/loghound-score (sessions); allow it in src/Panel/Query.php; SPEC.md and docs/SCHEMA.md. Renaming or removing a field is discussed first.

Change the beacon

public/b.js, public/collect.php, src/Beacon.php, src/Beacon/Doc.php; docs/BEACON.md. A test fails if the documented options fall behind the script.

Support a new log format

src/LogDetect.php, plus a fixture in tests/fixtures/.

Add a configuration option

Config::defaults() (and validate()), config/loghound.example.php, the settings page in src/Panel/Settings.php, and its documentation.

Add a command or a scheduled job

A script in bin/ following the existing ones, the bin list in composer.json, and for a schedule a unit and timer in install/ plus install.sh.

Change colours or layout of the panel

public/assets/css/panel.css, the only file where colours are defined.

02 · Tests, previews and releases
php tests/run.php # the whole suite, no network needed php tests/run.php tail # only tests whose name matches php tests/scan-secrets.php # make sure no secret is about to be committed php tools/panel-preview.php # a demo config, then: php -S 127.0.0.1:8099 -t public
  • A test file is tests/test_<name>.php returning named closures; the runner finds it by itself.
  • Versions are the headings in CHANGELOG.md and the matching git tags.
03 · The rules every contribution follows

They are written in CONTRIBUTING.md; in short:

  • No dependencies: no Composer packages, no npm, no build step, no CDN.
  • Security first: escape at output, user text to Solr only as bound parameters, allowlisted field names, safe paths, CSRF on every change, no secrets in code.
  • Honesty: an unknown number is absent, never zero; every verdict carries its reasons; limitations are documented.
  • Style: PSR-12, four spaces, single quotes, strict types, and the comment rules in CONTRIBUTING.md.
  • One change per pull request, with its documentation and a changelog entry.

Become a contributor

Read SPEC.md and CONTRIBUTING.md in the repository, then write to support@opensolr.com to ask for contributor access to Loghound or any other Opensolr open source project. Issues and pull requests on GitHub are open to everyone.

For developers

Loghound is open source and MIT licensed. Questions about the Opensolr half — the account, the indexes, the plan — go to opensolr.com/contact; questions about the software itself belong on GitHub.

Loghound Documentation