Skip to content

Commit

Permalink
Readme is mostly complete.
Browse files Browse the repository at this point in the history
Ready for push to github.
  • Loading branch information
evotodi committed Mar 4, 2020
1 parent 2ae4b1f commit 1e66d8b
Show file tree
Hide file tree
Showing 100 changed files with 6,500 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vendor/
/vendor/

composer\.lock

Expand All @@ -8,3 +8,5 @@ build/logs/
/tests/Controller/cache/
/tests/cache/
/config/
.idea/
var/
63 changes: 53 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
language: php
php:
- '7.0'
- '7.1'
- '7.2'
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
- $HOME/symfony-bridge/.phpunit

env:
global:
- PHPUNIT_FLAGS="-v"
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"

matrix:
fast_finish: true
include:
# Minimum supported dependencies with the latest and oldest PHP version
- php: 7.3
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
- php: 7.2
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"

# Test the latest stable release
- php: 7.1
- php: 7.2
- php: 7.3
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"

# Test LTS versions. This makes sure we do not use Symfony packages with version greater
# than 2 or 3 respectively. Read more at https://github.com/symfony/lts
- php: 7.2
env: DEPENDENCIES="symfony/lts:^3"

# Latest commit to master
- php: 7.2
env: STABILITY="dev"

allow_failures:
# Dev-master is allowed to fail.
- env: STABILITY="dev"

before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;

install:
- composer install
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
- ./vendor/bin/simple-phpunit install

script:
- mkdir -p build/logs
- bin/phpunit Tests --coverage-clover build/logs/coverage.xml

after_script:
- bin/coveralls -v --coverage_clover build/logs/coverage.xml
- composer validate --strict --no-check-lock
# simple-phpunit is the PHPUnit wrapper provided by the PHPUnit Bridge component and
# it helps with testing legacy code and deprecations (composer require symfony/phpunit-bridge)
- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Simple log Viewer Symfony Bundle

LogViewerBundle is a basic log viewer for symfony.
It allows you to list and view all of the symfony logs or external logs in one easy
place with level highlighting and level filtering.

## Installation
Install the package with:
```console
composer require evotodi/log-viewer-bundle
```
## Configuration

Create the routes yaml file `config/routes/evo_log_viewer_routes.yaml`

```yaml
evo_log_viewer:
resource: '@EvotodiLogViewerBundle/Resources/config/routes.xml'
prefix: '/logs'
```
Create the config yaml file `config/packages/evo_log_viewer.yaml`
```yaml
# List of log files to show
log_files:
log_name:
# Use full path
path: 'Some/Full/Path/to/Log/File.Ext'
# Pretty name to display else file name
name: My Log Files Pretty Name
# (Optional) Number of days to pull from log. See ddtraceweb/monolog-parser.
days: 0
# (Optional) See ddtraceweb/monolog-parser for patterns.
pattern: null
# (Optional) PHP style date format of log file
date_format: 'Y-m-d H:i:s'
# Show App logs in var/log
show_app_logs: true
```
## Advanced Configuration

#### pattern
The default pattern is `'/\[(?P<date>.*)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>[^\[\{].*[\]\}])/'`
\
You can change the regex pattern to match your log file but the pattern must include `P<date>`, `P<logger>`, `P<level>`, and `P<message>` as regex groups.
\
Example `'/\[(?P<date>.+)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>.*)/'`
\
See ddtraceweb/monolog-parser for other examples but ommit `P<context>` and `P<extra>`

#### days
Setting days in the config to 0 will parse to whole log which is the default. Days set to 5 for example will parse the log until the date portion of the pattern
if greater than DateTime('now') minus 5 days.

#### date_format
This should be the php date format of the date portion of the pattern. Default is Y-m-d H:i:s
/
[PHP DateFormat](https://www.php.net/manual/en/function.date.php)

## Thanks
Thanks to ddtraceweb/monolog-parser and greenskies/web-log-viewer-bundle.

## Contributions
Contributions are very welcome!

Please create detailed issues and PRs.

## License

This package is free software distributed under the terms of the [MIT license](LICENSE).
15 changes: 7 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "evotodi/log-viewer-bundle",
"description": "Desc goes here",
"description": "Simple log viewer bundle for symfony 4",
"type": "symfony-bundle",
"license": "MIT",
"authors": [
Expand All @@ -11,17 +11,16 @@
],
"require": {
"php": "^7.1.3",
"greenskies/collection": "^0.0.3",
"jdorn/sql-formatter": "^1.2"
},
"require-dev": {
"ext-json": "*",
"symfony/config": "^4.4",
"symfony/dependency-injection": "^4.4",
"symfony/http-kernel": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/phpunit-bridge": "^4.4",
"symfony/browser-kit": "^5.0"
"symfony/config": "^3.4 || ^4.4",
"symfony/dependency-injection": "^3.4 || ^4.4",
"symfony/http-kernel": "^3.4 || ^4.4",
"symfony/framework-bundle": "^3.4 || ^4.4",
"symfony/phpunit-bridge": "^3.4 || ^4.4",
"symfony/browser-kit": "^3.4 || ^5.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 2 additions & 5 deletions src/Parser/LineLogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class LineLogParser implements LogParserInterface
{

protected $pattern = [
'default' => '/\[(?P<date>.*)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>[^\[\{]+) (?P<context>[\[\{].*[\]\}]) (?P<extra>[\[\{].*[\]\}])/',
'error' => '/\[(?P<date>.*)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>(.*)+) (?P<context>[^ ]+) (?P<extra>[^ ]+)/'
'default' => '/\[(?P<date>.*)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>[^\[\{].*[\]\}])/',
];


Expand Down Expand Up @@ -51,9 +50,7 @@ public function parse($log, $dateFormat, $days = 1, $pattern = 'default')
'date' => $date,
'logger' => $data['logger'],
'level' => $data['level'],
'message' => $data['message'],
'context' => json_decode($data['context'], true),
'extra' => json_decode($data['extra'], true)
'message' => $data['message']
);

if (0 === $days) {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Resources/public/vendor/bootstrap/css/bootstrap.min.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Resources/public/vendor/bootstrap/js/bootstrap.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Resources/public/vendor/highlight/highlight.pack.js

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions src/Resources/public/vendor/highlight/styles/agate.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*!
* Agate by Taufik Nurrohman <https://github.com/tovic>
* ----------------------------------------------------
*
* #ade5fc
* #a2fca2
* #c6b4f0
* #d36363
* #fcc28c
* #fc9b9b
* #ffa
* #fff
* #333
* #62c8f3
* #888
*
*/

.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #333;
color: white;
}

.hljs-name,
.hljs-strong {
font-weight: bold;
}

.hljs-code,
.hljs-emphasis {
font-style: italic;
}

.hljs-tag {
color: #62c8f3;
}

.hljs-variable,
.hljs-template-variable,
.hljs-selector-id,
.hljs-selector-class {
color: #ade5fc;
}

.hljs-string,
.hljs-bullet {
color: #a2fca2;
}

.hljs-type,
.hljs-title,
.hljs-section,
.hljs-attribute,
.hljs-quote,
.hljs-built_in,
.hljs-builtin-name {
color: #ffa;
}

.hljs-number,
.hljs-symbol,
.hljs-bullet {
color: #d36363;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal {
color: #fcc28c;
}

.hljs-comment,
.hljs-deletion,
.hljs-code {
color: #888;
}

.hljs-regexp,
.hljs-link {
color: #c6b4f0;
}

.hljs-meta {
color: #fc9b9b;
}

.hljs-deletion {
background-color: #fc9b9b;
color: #333;
}

.hljs-addition {
background-color: #a2fca2;
color: #333;
}

.hljs a {
color: inherit;
}

.hljs a:focus,
.hljs a:hover {
color: inherit;
text-decoration: underline;
}
66 changes: 66 additions & 0 deletions src/Resources/public/vendor/highlight/styles/androidstudio.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Date: 24 Fev 2015
Author: Pedro Oliveira <kanytu@gmail . com>
*/

.hljs {
color: #a9b7c6;
background: #282b2e;
display: block;
overflow-x: auto;
padding: 0.5em;
}

.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
color: #6897BB;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-deletion {
color: #cc7832;
}

.hljs-variable,
.hljs-template-variable,
.hljs-link {
color: #629755;
}

.hljs-comment,
.hljs-quote {
color: #808080;
}

.hljs-meta {
color: #bbb529;
}

.hljs-string,
.hljs-attribute,
.hljs-addition {
color: #6A8759;
}

.hljs-section,
.hljs-title,
.hljs-type {
color: #ffc66d;
}

.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #e8bf6a;
}

.hljs-emphasis {
font-style: italic;
}

.hljs-strong {
font-weight: bold;
}
Loading

0 comments on commit 1e66d8b

Please sign in to comment.