SeunMatt / codeigniter-log-viewer

This is a simple Log Viewer for viewing Code Igniter logs on the browser and via API clients
MIT License
96 stars 39 forks source link

Message: preg_match(): Compilation failed: #13

Closed Andrewsuares closed 5 years ago

Andrewsuares commented 5 years ago

Hello, Any idea what could be wrong here?

CI_VERSION = '3.1.10'; PHP 7.3.4

A PHP Error was encountered

Severity: Warning

Message: preg_match(): Compilation failed: invalid range in character class at offset 33

Filename: src/CILogViewer.php

Line Number: 384

Backtrace:

File: /public_html/api/vendor/seunmatt/codeigniter-log-viewer/src/CILogViewer.php Line: 384 Function: preg_match

File: /public_html/api/vendor/seunmatt/codeigniter-log-viewer/src/CILogViewer.php Line: 285 Function: getLogLineStart

File: /public_html/api/vendor/seunmatt/codeigniter-log-viewer/src/CILogViewer.php Line: 172 Function: processLogs

File: /public_html/api/application/modules/f_cp/controllers/F_cp.php Line: 116 Function: showLogs

SeunMatt commented 5 years ago

Hi @Andrewsuares

I've not experienced that sort of error before. However, I need you to please do two things for me.

+1 for stating your PHP and CI versions. I'll be expecting your feedback.

Cheers.

Andrewsuares commented 5 years ago

Hello Seun, I've deployed CI on a large project and we're good with PHP 7.3. Going to be a bit hard for me to test 7.2. How do I enable to raw stack trace?

Please look at the link below. The preg function was updated in PHP 7.3. https://github.com/sunra/php-simple-html-dom-parser/issues/64

SeunMatt commented 5 years ago

Ha I see @Andrewsuares The package needs an update. I'll add it to the pipeline but can't say definitely when it'll be fixed.

In case you fix it in your code, please be so kind as to create a PR for it here as well. Cheers

matteopuppis commented 5 years ago

Easy fix: you should escape "-" character. Fix at line 30 from this: const LOG_LINE_START_PATTERN = "/((INFO)|(ERROR)|(DEBUG)|(ALL))[\s-\d:]+(-->)/"; to this const LOG_LINE_START_PATTERN = "/((INFO)|(ERROR)|(DEBUG)|(ALL))[\s-\d:]+(-->)/";

;)

matteopuppis commented 5 years ago

I think also the same problem is at line 31: from this: const LOG_DATE_PATTERN = "/(\d{4,}-[\d-:]{2,})\s([\d:]{2,})/"; to this: const LOG_DATE_PATTERN = "/(\d{4,}-[\d-:]{2,})\s([\d:]{2,})/";

matteopuppis commented 5 years ago

Another fix:

line 35 from this <a href="?f=<?= base64_encode($file); ?>" to this <a href="<?php echo base_url(); ?>logs/?f=<?= base64_encode($file); ?>" or you get path error if defined a base path for css/js....

semivan commented 5 years ago

Hello! Fixed bug: https://github.com/SeunMatt/codeigniter-log-viewer/pull/14

SeunMatt commented 5 years ago

Hello @Andrewsuares issue has been fixed in the new version release version 1.1.2

Andrewsuares commented 4 years ago

I finally got down to installing this update. Works brilliantly. The layout and the ability to see logs so easily just makes it great. Thank You for this!!

PS: Maybe you could do one to view the apache error log files :)