Skip to content

Commit

Permalink
FEATURE: Custom grouping patterns (#99)
Browse files Browse the repository at this point in the history
Logster has offered grouping of logs that have identical messages, severity and backtraces for quite some time now. This commit introduces grouping based on regular expression patterns that can be defined via Logster's UI. Each pattern will group logs that match into a single row and you'll be able to navigate through the messages/backtraces/envs of the individual logs when you select the row. The row will have the same timestamp as the most recent log contained in the group.

If you wish to undo the grouping, you can simply remove the pattern and all grouped logs will return to their original places in the logs list. You can also amend the pattern and any logs that don't match the pattern any more will be removed from the group and returned to their original place, and patterns that now do match the pattern will be added to the group.

To enable this feature, add this line `Logster.config.enable_custom_patterns_via_ui = true` to your app, and you'll see a small cog icon to the bottom right corner that takes you to the settings page where you can manage your grouping (and suppression) patterns.
  • Loading branch information
OsamaSayegh committed Dec 12, 2019
1 parent c8f8786 commit 24d6cc9
Show file tree
Hide file tree
Showing 67 changed files with 1,888 additions and 913 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in rack-log-viewer.gemspec
Expand Down
2 changes: 2 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/testtask"

Expand Down
122 changes: 69 additions & 53 deletions assets/javascript/client-app.js

Large diffs are not rendered by default.

1,139 changes: 580 additions & 559 deletions assets/javascript/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/stylesheets/client-app.css

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

2 changes: 1 addition & 1 deletion assets/stylesheets/vendor.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions bin/guard
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
Expand Down
2 changes: 2 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
Expand Down
4 changes: 2 additions & 2 deletions client-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ You will need the following things properly installed on your computer.
## Running / Development

* `ember serve`
* Visit your app at [http://localhost:4200](http://localhost:4200).
* Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).
* Visit your app at [http://localhost:4200/logs](http://localhost:4200).
* Visit your tests at [http://localhost:4200/logs/tests](http://localhost:4200/tests).

### Code Generators

Expand Down
52 changes: 16 additions & 36 deletions client-app/app/components/env-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ import { buildHashString } from "client-app/lib/utilities";
import Preload from "client-app/lib/preload";

export default Component.extend({
current: 1,

didUpdateAttrs() {
this.setProperties({
current: 1,
expanded: null
});
this.set("expanded", null);
},

currentEnv: computed("isEnvArray", "currentEnvPosition", function() {
if (this.isEnvArray) {
return this.message.env[this.currentEnvPosition];
} else {
return this.message.env;
}
}),

isEnvArray: computed("message.env", function() {
return Array.isArray(this.get("message.env"));
}),

html: computed("isEnvArray", "current", "expanded.[]", function() {
if (!this.get("isEnvArray")) {
html: computed("isEnvArray", "currentEnv", "expanded.[]", function() {
if (!this.isEnvArray) {
return buildHashString(this.get("message.env"));
} else {
const currentEnv = Em.$.extend(
{},
this.get("message.env")[this.get("current") - 1]
);
const currentEnv = Em.$.extend({}, this.currentEnv);
const expandableKeys = Preload.get("env_expandable_keys") || [];
expandableKeys.forEach(key => {
if (currentEnv.hasOwnProperty(key) && !Array.isArray(currentEnv[key])) {
const list = [currentEnv[key]];
this.get("message.env").forEach(env => {
this.message.env.forEach(env => {
if (env[key] && list.indexOf(env[key]) === -1) {
list.push(env[key]);
}
});
currentEnv[key] = list.length > 1 ? list : list[0];
}
});
return buildHashString(currentEnv, false, this.get("expanded") || []);
return buildHashString(currentEnv, false, this.expanded || []);
}
}),

Expand All @@ -50,31 +50,11 @@ export default Component.extend({
$elem.hasClass("expand-list")
) {
e.preventDefault();
if (!this.get("expanded")) {
if (!this.expanded) {
this.set("expanded", [dataKey]);
} else {
this.get("expanded").pushObject(dataKey);
this.expanded.pushObject(dataKey);
}
}
},

disableBackButtons: computed("current", function() {
return this.get("current") === 1;
}),

disableForwardButtons: computed("current", "message.env.length", function() {
return this.get("current") === this.get("message.env.length");
}),

actions: {
takeStep(dir) {
const amount = dir === "back" ? -1 : 1;
this.set("current", this.get("current") + amount);
},

bigJump(dir) {
const newCurrent = dir === "back" ? 1 : this.get("message.env.length");
this.set("current", newCurrent);
}
}
});
2 changes: 1 addition & 1 deletion client-app/app/components/message-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default Component.extend({
],

click() {
this.selectedMessage(this.get("model"));
this.selectRow();
},

willInsertElement() {
Expand Down
30 changes: 30 additions & 0 deletions client-app/app/components/page-nav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Component from "@ember/component";
import { computed } from "@ember/object";
import { equal } from "@ember/object/computed";

export default Component.extend({
classNames: ["nav-controls"],
classNameBindings: ["extraClasses"],
disableBackButtons: equal("position", 0),

disableForwardButtons: computed("position", "list.length", function() {
return this.position === this.get("list.length") - 1;
}),

displayNumber: computed("position", function() {
return this.position + 1;
}),

actions: {
takeStep(dir) {
const amount = dir === "back" ? -1 : 1;
const newPos = this.position + amount;
this.navigate(newPos);
},

bigJump(dir) {
const newPos = dir === "back" ? 0 : this.get("list.length") - 1;
this.navigate(newPos);
}
}
});
3 changes: 2 additions & 1 deletion client-app/app/components/patterns-list.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Component from "@ember/component";
import { not } from "@ember/object/computed";
import { not, equal } from "@ember/object/computed";
import { computed } from "@ember/object";
import Pattern from "client-app/models/pattern-item";
import { ajax } from "client-app/lib/utilities";

export default Component.extend({
immutable: not("mutable"),
showCounter: equal("key", "suppression"),

init() {
this._super(...arguments);
Expand Down

0 comments on commit 24d6cc9

Please sign in to comment.