# Alioth
The brightest star in the constellation of Ursa Major.  In this project, there is a set of unusual engineering efficiency and quality improvement tools.

## Building

Quick start:

```bash
make build
bin/logcov --help
```

## Log-based abnormal logic coverage improvement tool - logcov

Based on Log analysis to find the key (error) processing logic that is not covered by the test is the ability of logcov.

`logcov` uses the pipe-file architecture, which provides a set of independent commands, and each command constitutes a `filter` module. Integrating specific `filter` modules into different services to run, this tool can be easily integrated into CI and test systems.

Show the usage of `logcov` through help query

```
$ ./logcov help
logcov is a tool that computes the coverage of exception error handling by analyzing the testing log

Usage:
  logcov [command]

Available Commands:
  extract     Extract logs pattern and reference code information from codebase and compilation
  scan        Scan program log files and calculate the log coverage result
  merge       Merge multiple log coverage results
  analyze     Analyze the coverage result and output the analysis result report
  debug       debug provides various methods to analyze log pattern, coverage, unknown log
  help        Help about any command

Use "logcov [command] --help" for more information about a command.
 ```

### extract log pattern from code

`logcov extract` extracts logs pattern and reference code information from codebase.

```
$ ./logcov help extract
Extract logs pattern and reference code information from codebase.

Usage:
 logcov extract [--codebase=repo-directory] [--filter=log-filter-config] [--output=log-pattern-file]

Flags:
     --codebase string       Source codebase directory for extracting log information (default "./")
     --concurrency int    compile package and analyze code concurrency (default 9)
     --filter string         the log filter, using log level `log-level:[Error|Fatal]` or log keywords `keywords:[regex1,regex2]`, (default "")
     --output string         the output file that stores the extracted log pattern and reference code information (default "./${codebase-dirname}.logpattern")
```

`--filter` support configuration file format:

``` toml
loglevel=["fatal", "error"]
```

###  scan log file and statistics log coverage

`logcov scan` scans one or more log files run by the program, calculates the log coverage, and records the result in the log pattern.

```
$ ./logcov help scan
Scan program log files and calculate the log coverage result

Usage:
 logcov scan [--log-pattern=log-pattern-file] [--logs=file,file]

Flags:
     --log-pattern string     the file that stores the extracted log pattern information, `log scan` would also add log coverage into it
     --logs string            the program runtime log files, files are separated by commas
     --concurrency int        scan log pipeline concurrency (default 9)
```

###  merge multiple log coverages

`logcov merge` merge coverage generated by multiple `log scan`.

```
$ ./logcov help merge
Merge multiple log coverage results

Usage:
 logcov merge [--log-patterns=log-pattern-file,log-pattern-file] [--output=log-coverage-file]

Flags:
     --log-patterns string     the log pattern files, files are separated by commas
     --output string           the merged log coverage file (contain log coverage, reference log code information) (default "./logcoverage")
```

### analyze log coverage and output the reporter

`logcov analyze` analyze coverage and output analysis report.

```
$ ./logcov help analyze
Analyze the coverage result and output the analysis result report

Usage:
 logcov analyze [--log-coverage=log-coverage-file] [--output=report-file]

Flags:
     --log-coverage string    the log coverage file (contain log coverage, reference code information)
     --output string          output report of log coverage analysis results (default stdout)
     --template string        output report template
```
