onlylogs 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b9969627b74355a1b0c31a2314961e45ed78558c10b2c181c83c8303c4128a5
4
- data.tar.gz: b01ad9a6faa8d94e982a938d8c1b7afa4e25fe277ddbd6d0468546d9c9272f64
3
+ metadata.gz: e6cd6af6ff916e3ce2fb4ad8d4cf77518b681b86246f7c662390e8e66acadc10
4
+ data.tar.gz: 88b5108172130b635097dcad9c1fa55bd377e59f62d8ee0acbffd3b51c203404
5
5
  SHA512:
6
- metadata.gz: d40db595e6c21fdff61f5f0f0c0eef96a1be49b35bb79a0e57fc0676b9fdde401d7e644a42a9523f54a79f00150646e0413c352a774437c33e6c20f60b6ed46c
7
- data.tar.gz: 433b9d90c250d86e88117f4706304a571b6f34fc72992209aab90427ebb29cc1162dcf9d09a435f23244c55f1c79f3b4fb15985c6c7e189673512587feac7940
6
+ metadata.gz: 4d4d33d4063e8bdd61e436f92ad5fe1156693003a98bbc6a7debcc8d0a954fcd77f980222f88c0f7181c20b5fd5f2aa073504df37f22a3dfc08159bfba4c0a3a
7
+ data.tar.gz: 1eb8bf75d9c8b6f241b08009797d3db0b6c806319b57d69982c85eeb537eb6103904f323664e752f87bbc1ea97938300e11c8912ca951adbf81784ed130bde91
data/README.md CHANGED
@@ -18,7 +18,7 @@ If you already have a disk, you can just keep there also your log files (as well
18
18
 
19
19
  This section explains how to setup onlylogs to self host your logs and access them directly from your Rails app.
20
20
 
21
- If instead you want to stream your logs to https://onlylogs.io, head to the onlylogs.io instructions page.
21
+ If instead you want to stream your logs to https://onlylogs.io, head to [the onlylogs.io instructions page](https://onlylogs.io/instructions).
22
22
 
23
23
  Add this line to your application's Gemfile:
24
24
 
@@ -3,10 +3,6 @@ import { Controller } from "@hotwired/stimulus"
3
3
  export default class AutoSubmitController extends Controller {
4
4
  submit(event) {
5
5
  const form = event.target.form
6
- if (form.requestSubmit) {
7
- form.requestSubmit()
8
- } else {
9
- form.submit()
10
- }
6
+ form.requestSubmit ? form.requestSubmit() : form.submit();
11
7
  }
12
8
  }
data/bin/super_grep ADDED
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env bash
2
+ export LC_ALL=C
3
+
4
+ # Parse arguments
5
+ max_matches=""
6
+ start_position=""
7
+ end_position=""
8
+ block_size="${BLOCK_SIZE:-8M}"
9
+
10
+ while [[ $# -gt 0 ]]; do
11
+ case "$1" in
12
+ --max-matches)
13
+ max_matches="$2"
14
+ shift 2
15
+ ;;
16
+ --start-position)
17
+ start_position="$2"
18
+ shift 2
19
+ ;;
20
+ --end-position)
21
+ end_position="$2"
22
+ shift 2
23
+ ;;
24
+ --regexp)
25
+ regexp_mode=true
26
+ shift
27
+ ;;
28
+ *)
29
+ break
30
+ ;;
31
+ esac
32
+ done
33
+
34
+ query="$1"
35
+ file="$2"
36
+
37
+ # Validate file
38
+ [ -f "$file" ] || exit 1
39
+
40
+ # Prepare query regex based on mode
41
+ if [ "$regexp_mode" = true ]; then
42
+ # Translate \d to [0-9] for grep -E compatibility
43
+ query_regex=$(printf "%s" "$query" | sed 's/\\d/[0-9]/g')
44
+ else
45
+ # Escape special characters
46
+ query_regex=$(printf "%s" "$query" | sed -E 's/([][{}()*+?.\\^$|])/\\\1/g')
47
+ fi
48
+
49
+ # Replace spaces with placeholder to avoid sed escaping hell for color regex
50
+ placeholder="__COLOR_REGEX__"
51
+ query_regex=$(printf "%s" "$query_regex" | sed -E "s/ +/([[:space:]]|$placeholder)+/g")
52
+
53
+ # Use bash variable substitution to insert the actual color regex
54
+ ESC=$(printf '\033')
55
+ actual_color_regex="${ESC}\\[[0-9;]*m"
56
+ query_regex="${query_regex//$placeholder/$actual_color_regex}"
57
+
58
+
59
+ # Build grep command
60
+ grep_cmd=(grep -E -h) # -h = no filename (portable)
61
+ if [ -n "$max_matches" ]; then
62
+ grep_cmd+=(-m "$max_matches") # -m = max count (portable)
63
+ fi
64
+
65
+ # Handle byte range if specified
66
+ if [ -n "$start_position" ] || [ -n "$end_position" ]; then
67
+ file_size=$(wc -c < "$file")
68
+ range_start=${start_position:-0}
69
+ range_end=${end_position:-$file_size}
70
+ range_size=$((range_end - range_start))
71
+
72
+ # Validate range
73
+ if [ $range_start -lt 0 ] || [ $range_size -le 0 ] || [ $range_start -ge $file_size ]; then
74
+ exit 0
75
+ fi
76
+
77
+ # Adjust if exceeds file size
78
+ [ $range_end -gt $file_size ] && range_end=$file_size && range_size=$((range_end - range_start))
79
+
80
+ # Extract byte range using dd
81
+ start_mb=$((range_start / 1048576))
82
+ start_offset=$((range_start % 1048576))
83
+ count_mb=$(((range_size + 1048576 - 1) / 1048576))
84
+
85
+ dd if="$file" bs="$block_size" skip=$start_mb count=$count_mb 2>/dev/null | \
86
+ dd bs=1 skip=$start_offset count=$range_size 2>/dev/null | \
87
+ "${grep_cmd[@]}" "$query_regex"
88
+ else
89
+ # Search entire file
90
+ "${grep_cmd[@]}" "$query_regex" "$file"
91
+ fi
data/bin/super_ripgrep ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ export LC_ALL=C
3
+
4
+ # Parse arguments
5
+ max_matches=""
6
+ start_position=""
7
+ end_position=""
8
+ block_size="${BLOCK_SIZE:-8M}"
9
+
10
+ while [[ $# -gt 0 ]]; do
11
+ case "$1" in
12
+ --max-matches)
13
+ max_matches="$2"
14
+ shift 2
15
+ ;;
16
+ --start-position)
17
+ start_position="$2"
18
+ shift 2
19
+ ;;
20
+ --end-position)
21
+ end_position="$2"
22
+ shift 2
23
+ ;;
24
+ --regexp)
25
+ regexp_mode=true
26
+ shift
27
+ ;;
28
+ *)
29
+ break
30
+ ;;
31
+ esac
32
+ done
33
+
34
+ query="$1"
35
+ file="$2"
36
+
37
+ # Validate file
38
+ [ -f "$file" ] || exit 1
39
+
40
+ # Prepare query regex based on mode
41
+ if [ "$regexp_mode" = true ]; then
42
+ # Translate \d to [0-9] for consistency
43
+ query_regex=$(printf "%s" "$query" | sed 's/\\d/[0-9]/g')
44
+ else
45
+ # Escape special characters
46
+ query_regex=$(printf "%s" "$query" | sed -E 's/([][{}()*+?.\\^$|])/\\\1/g')
47
+ fi
48
+
49
+ # Replace spaces with placeholder to avoid sed escaping hell for color regex
50
+ placeholder="__COLOR_REGEX__"
51
+ query_regex=$(printf "%s" "$query_regex" | sed -E "s/ +/([[:space:]]|$placeholder)+/g")
52
+
53
+ # Use bash variable substitution to insert the actual color regex
54
+ # Ripgrep supports \x1b directly
55
+ actual_color_regex='\x1b\[[0-9;]*m'
56
+ query_regex="${query_regex//$placeholder/$actual_color_regex}"
57
+
58
+ # Build ripgrep command
59
+ rg_cmd="rg --color=never --no-filename"
60
+ [ -n "$max_matches" ] && rg_cmd="$rg_cmd --max-count=$max_matches"
61
+
62
+ # Handle byte range if specified
63
+ if [ -n "$start_position" ] || [ -n "$end_position" ]; then
64
+ file_size=$(wc -c < "$file")
65
+ range_start=${start_position:-0}
66
+ range_end=${end_position:-$file_size}
67
+ range_size=$((range_end - range_start))
68
+
69
+ # Validate range
70
+ if [ $range_start -lt 0 ] || [ $range_size -le 0 ] || [ $range_start -ge $file_size ]; then
71
+ exit 0
72
+ fi
73
+
74
+ # Adjust if exceeds file size
75
+ [ $range_end -gt $file_size ] && range_end=$file_size && range_size=$((range_end - range_start))
76
+
77
+ # Extract byte range using dd
78
+ start_mb=$((range_start / 1048576))
79
+ start_offset=$((range_start % 1048576))
80
+ count_mb=$(((range_size + 1048576 - 1) / 1048576))
81
+
82
+ dd if="$file" bs="$block_size" skip=$start_mb count=$count_mb 2>/dev/null | \
83
+ dd bs=1 skip=$start_offset count=$range_size 2>/dev/null | \
84
+ $rg_cmd -e "$query_regex"
85
+ else
86
+ # Search entire file
87
+ $rg_cmd -e "$query_regex" "$file"
88
+ fi
@@ -1,3 +1,3 @@
1
1
  module Onlylogs
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onlylogs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Rodi
@@ -29,6 +29,8 @@ email:
29
29
  - alessandro.rodi@renuo.ch
30
30
  executables:
31
31
  - onlylogs_sidecar
32
+ - super_grep
33
+ - super_ripgrep
32
34
  extensions: []
33
35
  extra_rdoc_files: []
34
36
  files:
@@ -68,6 +70,8 @@ files:
68
70
  - app/views/onlylogs/shared/_log_container.html.erb
69
71
  - app/views/onlylogs/shared/_log_container_styles.html.erb
70
72
  - bin/onlylogs_sidecar
73
+ - bin/super_grep
74
+ - bin/super_ripgrep
71
75
  - config/importmap.rb
72
76
  - config/routes.rb
73
77
  - db/migrate/20250902112548_create_books.rb