Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
cl-logfile-actions
cl-logfile-actions
Commits
394ce603
Commit
394ce603
authored
Jun 29, 2020
by
Philipp Marek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More stuff.
parent
21070b69
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
3 deletions
+51
-3
cl-logfile-actions.asd
cl-logfile-actions.asd
+2
-1
src/config.lisp
src/config.lisp
+5
-0
src/logfile-reader.lisp
src/logfile-reader.lisp
+40
-0
src/package.lisp
src/package.lisp
+2
-2
src/read-config.lisp
src/read-config.lisp
+2
-0
No files found.
cl-logfile-actions.asd
View file @
394ce603
...
...
@@ -3,8 +3,9 @@
:license
"LGPL3"
:author
"Philipp Marek <philipp@marek.priv.at>"
:depends-on
(
:iterate
:interpol
:
cl-
interpol
:uiop
:osicat
:fiveam
:alexandria
)
:around-compile
(
lambda
(
thunk
)
...
...
src/config.lisp
0 → 100644
View file @
394ce603
(
in-package
:cl-logfile-actions
)
(
defvar
*quit*
nil
"Stop cleanly."
)
src/logfile-reader.lisp
View file @
394ce603
(
in-package
:cl-logfile-actions
)
;; Reading a logfile has a few important "edge" cases.
;;
;; - The file might get rotated
;; - The file might become truncated
;; - Upon an error NUL bytes might come up
;; - It might not be UTF8
;;
;; - The logfile reading process should restart at the last position,
;; but must take care about the points above!
;;
;; We need to handle all these cases.
;;
;;
;; Furthermore,
;;
;; - we shouldn't use too much CPU - so avoid polling, if possible.
(
defun
get-a-file-ID
(
path
)
"Returns the block device and inode; we want to be sure that this is the same
file as last time.
Note: this might break on NFS (not a usecase now, only local files).
Note: No idea about windows compatibility."
(
let
((
stat
(
osicat-posix:stat
path
)))
(
with-slots
(
stat-ino
)
stat
(
format
nil
"0x~x:~d"
(
osicat-posix:stat-dev
stat
)
(
osicat-posix:stat-ino
stat
)))))
(
defun
continue-logfile-from
(
path
byte-offset
)
(
iter
(
until
*quit*
)
(
sleep
0.1
)))
(
defun
read-logfile
(
path
)
(
let
((
file-id
(
get-a-file-ID
path
)))
;; compare to last-known position
(
continue-logfile-from
path
0
)))
src/package.lisp
View file @
394ce603
(
defpackage
:cl-logfile-actions
(
:nickname
:l-a
)
(
:nickname
s
:l-a
)
(
:use
:cl
:iterate
)
(
:export
))
(
defpackage
:cl-logfile-actions/test
(
:nickname
:l-a-test
)
(
:nickname
s
:l-a-test
)
(
:use
:cl
:iterate
))
src/read-config.lisp
0 → 100644
View file @
394ce603
(
in-package
:cl-logfile-actions
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment