Skip to content

Commit

Permalink
Enable font overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
ilhan-mstf committed Dec 6, 2020
1 parent 1675cba commit e8b403d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 32 deletions.
20 changes: 18 additions & 2 deletions DetailedDescription.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
The purpose of this extension is to group logs visually on AWS CloudWatch. There are three rules:
- Set a different background color for each log group of AWS Lambda invocation. Therefore, you can easily recognize beginning, body and end of the logs of the same invocation.
- Set font weight of lines having `REPORT` and `[ERROR]` keywords to bold.
- Set font weight of lines having `REPORT`, `[ERROR]` and `[Error ` keywords to bold.
- Set text color of ANSI terminal codes in the logs. (by https://github.com/oguimbal)

Further, there is two functionality for better log viewing experience (by https://github.com/oguimbal):
- Switching to fullscreen,
- Refreshing the logs periodically to load new items.

This extension doesn't collect any user and web page information. It only runs on AWS CloudWatch Logs web page. It is free to use.

Overhead is very low, colorize operation takes ~7 milliseconds, listen operation for new event logs takes just ~0.5 milliseconds in every second.
Expand All @@ -11,9 +15,21 @@ Contributions are welcome. To contribute please visit project page: https://gith

Release Log:
--------------------
Version 0.5.1:
- Enable font override on new ui

Version 0.5.0:
- Handle new ui
- Case insensitive error line search

Version 0.4.11:
- Add `[Error ` as a special line to make it bold
- Add "Fullscreen" and "Follow tail" buttons

Version 0.3.8:
- Set text color of ANSI terminal codes
- Update extension logo
- Improve performance

Version 0.2.1:
- Make bold font weight of `REPORT` and `[ERROR]` lines
- Make bold font weight of `REPORT` and `[ERROR]` lines
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Contributions are welcome. Please follow the standart.js convention if you want
### Contributors
- [@oguimbal](https://github.com/oguimbal)
- [@svikrant2014](https://github.com/svikrant2014)
- [@ktwbc](https://github.com/ktwbc)

### Open Source
- [ansi_up.js](http://github.com/drudru/ansi_up)
43 changes: 14 additions & 29 deletions colorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
* Contributors:
* - Olivier Guimbal, https://github.com/oguimbal
* - Vikrant Sharma, https://github.com/svikrant2014
* - Kris Thom White, https://github.com/ktwbc
*/

'use strict'

/* global AnsiUp, localStorage */

const colors = ['#FCA17D', '#F9DBBD', '#ADFFE5', '#FFF399', '#CDC7E5', '#FCD0A1', '#F6A5A2', '#A3F7B5', '#D8B4E2', '#C4F4C7', '#C7FFDA', '#D9FFF8', '#E8E1EF', '#E6DBD0', '#FAFFD8']
const colors = ["#F9DBBD", "#CDC7E5", "#F6A5A2", "#FFF399", "#C4F4C7", "#E8E1EF", "#D9FFF8", "#ADFFE5", "#E6DBD0", "#C7FFDA", "#FCA17D", "#FCD0A1", "#FAFFD8", "#A3F7B5", "#D8B4E2"]

const ansiTransform = new AnsiUp()
delete window.AnsiUp // just delete it so its hidden from global space
Expand Down Expand Up @@ -281,22 +282,7 @@ function refreshAutoRefresh () {

function refreshFonts () {
const elements = getElements()
const eventIds = Array.from(
new Set(
elements
.filter(isStartOrEnd)
.map(getEventId)))
if (elements && eventIds) {
if (fontsOn()) {
eventIds.forEach(id => elements
.filter(element => hasId(element, id))
.forEach(element => changeFontElement(element, 'set')))
} else {
eventIds.forEach(id => elements
.filter(element => hasId(element, id))
.forEach(element => changeFontElement(element, 'clear')))
}
}
elements.forEach(element => changeFontElement(element, fontsOn() ? 'set' : 'clear'))
}

function refreshTail () {
Expand Down Expand Up @@ -366,7 +352,7 @@ function colorizeElement (element, color) {
return element
}

function changeFontElement (element, action = undefined) {
function changeFontElement (element, action) {
if (element.dataset.isFontHandled !== 'yes' || action) {
element.dataset.isFontHandled = 'yes'
element.height = '20px'
Expand Down Expand Up @@ -419,7 +405,7 @@ function getUniqueEventIds (eventIds) {
}

function changeFontOnGroup (elements) {
elements.forEach(element => changeFontElement(element))
elements.forEach(changeFontElement)
}

function colorizeGroup (elements) {
Expand All @@ -434,28 +420,27 @@ function decorateGroups (elements) {
eventIds.forEach(
id => {
colorizeGroup(elements.filter(element => hasId(element, id)))
if (newDesign && fontsOn()) changeFontOnGroup(elements.filter(element => hasId(element, id)))
if (newDesign && fontsOn()) changeFontOnGroup(elements)
})
}
}

function applyAnsiTransform (e) {
const txt = e.childNodes[0]
const textValue = txt.textContent || ''
if (/(^|\x1b)\[(\d+)m/.test(textValue)) {
e.classList.add('ansiColorized')
e.innerHTML = ansiTransform.ansi_to_html(textValue)
if (e) {
const txt = e.childNodes[0]
const textValue = txt.textContent || ''
if (/(^|\x1b)\[(\d+)m/.test(textValue)) {
e.classList.add('ansiColorized')
e.innerHTML = ansiTransform.ansi_to_html(textValue)
}
}
}

function colorizeAnsi (elements) {
for (let e of elements) {
if (e.dataset.isAnsiColorizedHandled !== 'yes') {
e.dataset.isAnsiColorizedHandled = 'yes'
if (e.childNodes.length !== 1 || e.childNodes[0].nodeType !== 3) {
continue // expecting only one child text node
}
applyAnsiTransform(e)
applyAnsiTransform(e.getElementsByClassName("logs__log-events-table__cell")[1])
}
}
}
Expand Down
Binary file removed colorize_cloudwatch_logs.zip
Binary file not shown.
1 change: 1 addition & 0 deletions hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ <h4>Group logs visually on AWS CloudWatch</h4>
<p>If you enable "Follow tail", it refreshes the logs periodically to load new items.</p>
<p>This extension doesn't collect any user and web page information. It only runs on AWS CloudWatch Logs web page. It is free to use.</p>
<p><a href="https://github.com/ilhan-mstf/colorize_cloudwatch_logs">Github project</a></p>
<p>v0.5.1</p>
</body>
</html>
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Colorize AWS CloudWatch Logs",
"description" : "Group logs visually on AWS CloudWatch",
"version": "0.5.0",
"version": "0.5.1",
"homepage_url": "https://github.com/ilhan-mstf/colorize_cloudwatch_logs",
"manifest_version": 2,
"icons": {
Expand Down

0 comments on commit e8b403d

Please sign in to comment.