Build a Python 3.12+ CLI tool named "peoplesoft-log-analyzer" that scans Oracle PeopleSoft PeopleTools PIA/WebLogic web server logs and surfaces errors/warnings for troubleshooting. This is a read-only analysis tool: it must never modify, move, or delete anything under the scanned log directory. Packaging conventions (match this repo's house style): - hatchling build backend in pyproject.toml - flat top-level package layout, e.g. `peoplesoft_log_analyzer/` (not `src/`), matching sibling projects like afk_developer and peoplesoft-pia-tools/tools - pytest for tests, ruff for lint/format - a console entry point script `peoplesoft-log-analyzer` plus `python -m peoplesoft_log_analyzer` support - a README with install/usage examples ## Input shape The tool scans a root directory containing one or more "domain" subdirectories (names like WEBDOM01, WEBDOM02, WEBDOME01 .. WEBDOME08 -- the exact set and count varies and must not be hardcoded). Each domain subdirectory may contain these files directly inside it: - PIA_weblogic.log - PIA_stdout.log - PIA_stderr.log - asp_system.log - PIA_access.log, PIA_shutdown.log, PIA_shutdownerr.log, PIA.pid (often empty or absent -- skip silently, do not error) The root directory itself (a sibling of the domain folders, not inside them) may also contain one plain-text file per domain named `.log` (e.g. `WEBDOM01.log`) -- a PSADMIN domain boot/admin log. There may also be a `manifest.json` at the root describing what was pulled. Do NOT require or depend on manifest.json -- discover domain folders and files by walking the directory tree and matching known filenames case-sensitively. Unknown files should be skipped and counted as "skipped/unrecognized", never raise an error and never abort the whole scan because one file is missing, empty, or unreadable (log a per-file warning and continue). ## Critical performance constraint Individual files can exceed 3-4 GB (this is a real, current production scenario -- PIA_stdout.log alone can be 300+ MB per domain). The tool MUST stream every file line-by-line (buffered iteration) and must never read an entire file into memory (`.read()` / `.readlines()` on a whole file are forbidden for these log files). Use compiled regexes, O(n) single-pass scanning, and constant/bounded memory for aggregation (aggregate by a normalized signature -- see below -- not by storing every raw line). ## Log formats to parse (one parser per format) ### 1. PIA_weblogic.log -- WebLogic Server domain log Multi-field record, one record per line, fields delimited by `<...>`: ``` #### <> <> <1784300380366> <[severity-value: 64] [rid: 0] > #### <> <> <1784300686714> <[severity-value: 32] [rid: 0:33] > ``` Field order: timestamp (with embedded timezone name, e.g. "Pacific Daylight Time" / "Pacific Standard Time" -- parse and normalize to Pacific time), severity (`Info`, `Notice`, `Warning`, `Error`, `Critical`, `Alert`, `Emergency`), subsystem, hostname, server name, thread, a doubled `<<...>>` field, an often-empty field, a transaction/diagnostic id, an epoch millis timestamp, a `[severity-value: N] [rid: ...]` block, a `BEA-NNNNNN` message id, and finally the free-text message (which itself may legitimately contain `<` and `>` characters, so do not naively split on those -- parse the fixed leading fields positionally/by regex and treat everything after the last recognized `` field as the message). A record can rarely wrap onto a continuation line with no `####<` prefix; append continuation lines to the previous record's message. ### 2. PIA_stdout.log and PIA_stderr.log -- raw JVM stdout/stderr These are NOT timestamped by WebLogic in this environment -- they are the JVM's raw console redirect. Do not assume a timestamp is present; the parsed timestamp field must be optional/None for entries from these two files unless a line happens to embed one itself. Content is a mix of: - benign repeated JVM startup noise, e.g.: ``` WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by weblogic.platform.VM (file:/u01/app/oracle/product/pt/bea/wlserver/modules/com.bea.core.utils.full.jar) to field java.net.Socket.impl ``` - raw Java exception stack traces with no consistent prefix, e.g.: ``` com.peoplesoft.pt.integrationgateway.common.GeneralFrameworkException: Cannot establish HTTP connection. at com.peoplesoft.pt.integrationgateway.targetconnector.HttpTargetConnector.send(HttpTargetConnector.java:300) at com.peoplesoft.pt.integrationgateway.service.BasicConnectorInvocator.execute(BasicConnectorInvocator.java:131) ... (many more "at ..." frames) Caused by: java.net.ConnectException: Connection refused at ... (more frames) ``` Parsing rules: - A line matching `^\S.*(Exception|Error)(:.*)?$` (i.e. starts at column 0, not indented, looks like a `package.ClassName[Exception|Error]: message`) starts a new exception record. - Subsequent lines starting with whitespace then `at ` are stack frames; accumulate them under the current exception record. Also accumulate `Caused by: ...` lines and their own `at ` frames as part of the same record (nested cause chain). The record ends when a non-continuation line (does not start with whitespace+`at ` and is not `Caused by:`) is seen, or EOF. - A line starting with `WARNING:` (not part of an exception block) is a standalone WARN entry. - Everything else is low-value noise -- do not surface it as an issue by default (still count total lines scanned). ### 3. asp_system.log -- PeopleSoft PSTools ASP/PIA system log ``` [ WARN] 2026-07-22 12:53:10,048 - 0: GetField: Field 'PSNODE_WRK.WRKPASSWORD' not found in scroll level 0. (2,155) PSTRUSTNODE_WRK.FUNCLIB_01.FieldFormula Name:EnableDisableNodePasswordandButton PCPC:2263 Statement:54 Called from:PSMSGNODEDEFN.NODE_TYPE.RowInit Statement:28 [ WARN] 2026-07-22 12:53:10,052 - 1: Error loading Component Processor {GS_NODE_DEFNS} (91,24) ``` Fields: ``, ``, ``, `[ LEVEL]` (seen: `WARN`, but design for `INFO`/`ERROR`/`DEBUG` too, padding inside the brackets varies), a local timestamp `YYYY-MM-DD HH:MM:SS,mmm` (already Pacific local time -- do not re-convert), then ` - ` and the message. A line with no `` prefix at all (e.g. `Called from:...`, or the banner block after "Re-read PIA site configuration" with `Key [Value]` rows) is a continuation of the previous record -- append it to that record's message rather than treating it as a new/malformed entry. ### 4. `.log` at the root (e.g. WEBDOM01.log) -- PSADMIN domain log Generic plaintext with no fixed schema across versions. Implement a best-effort generic line scanner: flag lines containing case-insensitive `error`, `fail`, `exception`, `critical` as WARN/ERROR-ish signals (severity ERROR if the word `error`/`exception`/`critical` appears, else WARN for `fail`/`warn`); everything else is not surfaced. Keep this parser intentionally simple/best-effort and clearly labeled as lower-confidence in the code and docs. ### Unknown/unrecognized files Skip with a per-file note in the run summary ("skipped: (unrecognized type)" or "skipped: (empty)"). Never crash the whole scan. ## Normalization and aggregation Define one severity enum used across all parsers, ordered: DEBUG < INFO < NOTICE < WARN < ERROR < CRITICAL < UNKNOWN(lowest confidence, sorts like WARN). Map each format's native levels onto it (WebLogic Warning->WARN, Error->ERROR, Critical/Alert/Emergency->CRITICAL, etc). Each parsed record becomes a normalized `LogEntry`: domain, source file, severity, timestamp (optional), raw message, and a derived `signature` used to group repeats of "the same issue" so a burst of thousands of identical messages becomes one aggregated row, not thousands of lines: - exception records: signature = exception class name + first non-JDK/non-weblogic-internal stack frame if present, else the exception class name + first line of message. - WebLogic records: signature = the `BEA-NNNNNN` message id (message text varies with substituted numbers/hosts but the id is stable). - asp_system records: signature = the message with variable tokens generalized (strip request ids, thread numbers, GUIDs, quoted field/record names' distinguishing values, timestamps, and numeric literals -- keep the structural template, e.g. "GetField: Field '' not found in scroll level ..."). - generic domain-log records: signature = the matched line with obvious variable substrings (timestamps, numbers, ids) stripped. An aggregated `Issue` tracks: signature, severity, total count, first_seen, last_seen (when timestamps are available), the set of affected domains, the set of affected source files, and one representative full example entry. ## CLI Use click (already the convention in this repo's other CLIs, e.g. peoplesoft-pia-tools/tools/cli.py). Subcommands: - `list-domains ROOT_DIR` -- walk ROOT_DIR, print discovered domains, which known files exist per domain, and their sizes, without parsing content. A quick sanity check before a full scan. - `scan ROOT_DIR [--min-severity WARN] [--since ISO_TIMESTAMP] [--domain NAME (repeatable)] [--format text|json|csv] [--top N (default 25)] [--output PATH]` -- walks, parses, aggregates, and prints/writes a report: - overview: total lines scanned, bytes scanned, elapsed time, entry counts by severity, entry counts by domain, entry counts by log file type, skipped-file list; - top N aggregated issues sorted by count desc (rank, severity, count, first_seen, last_seen, affected domain count, signature, one truncated example); - `--format json` and `--format csv` emit the FULL aggregated issue list (not just top N) for downstream dashboards/spreadsheets; `--format text` (default) is a readable console report showing the overview plus top N. Print progress (e.g. current file being scanned, running line count) to stderr so it is usable on multi-GB real corpora without looking hung. ## Tests Do not use the real multi-gigabyte production corpus as a test fixture (it is external to the repo and far too large). Instead create small synthetic fixture files under `tests/fixtures/` for each of the four formats above, built from the example lines given in this spec plus these edge cases: - a WebLogic record with `Error` and one with `Critical` severity; - a multi-line Java exception with a `Caused by:` chain in a stdout fixture; - a standalone `WARNING:` stdout line outside any exception block; - an asp_system WARN record followed by a `Called from:` continuation line, and the "Re-read PIA site configuration" banner block as another continuation example; - an empty file (e.g. an empty `PIA_access.log`) that must be skipped cleanly; - an unrecognized filename that must be skipped and reported. Write unit tests asserting correct severity mapping, correct multi-line grouping, correct signature-based aggregation/counts, correct min-severity and domain filtering, and that `scan` never raises on the fixture set. Include at least one test that synthesizes a >10MB fixture (repeat a template line) to assert the scan completes and memory stays bounded (assert on wall-clock being reasonable, not on exact memory use). ## README Document install (`pip install -e .`), the two subcommands with real example invocations against a path like `F:\storage-dev\peoplesoft-pia-tools\storage\downloads\pull-20260722T223816Z`, and a short explanation of the signature-based aggregation so a reader understands why 50,000 raw lines can collapse into a handful of report rows.