# Usage examples

### Capture all new lines from .log files

```bash
advlogparser /var/log/myapp '.*\.log'
```

### Filter only lines containing ERROR

```bash
advlogparser /var/log/myapp '.*\.log' '(?i)error' 'myapp_errors'
```

### Filter by file name and content, with a custom index directory

```bash
advlogparser --idx-dir /var/spool/pandora /opt/app/logs 'access.*\.log' '^50[023]' 'http_errors'
```

### Typical Execution Flow

```bash
# First execution: creates indexes, no output
advlogparser /tmp/logs '.*\.log' 'ERROR' 'my_source'

# New lines are written to the log
printf 'INFO: ok\nERROR: disk full\n' >> /tmp/logs/app.log

# Second execution: only captures new lines containing ERROR
advlogparser /tmp/logs '.*\.log' 'ERROR' 'my_source'
```

Generated output:

```xml
<log_module>
  <source><![CDATA[my_source]]></source>
  <data encoding="base64">RVJST1I6IGRpc2NvIGxsZW5v</data>
</log_module>
```

```bash
# Third execution with no changes: no output
advlogparser /tmp/logs '.*\.log' 'ERROR' 'my_source'
```