Skip to content

Commit 2f40d6a

Browse files
71zenithport19x
andauthored
feat: initial logger support (#1370)
Co-authored-by: port19 <[email protected]>
1 parent 5e4ad5c commit 2f40d6a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ani-cli

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
version_number="4.8.13"
3+
version_number="4.9.0"
44

55
# UI
66

@@ -45,6 +45,8 @@ help_info() {
4545
Download the video instead of playing it
4646
-D, --delete
4747
Delete history
48+
-l, --logview
49+
Show logs
4850
-s, --syncplay
4951
Use Syncplay to watch with friends
5052
-S, --select-nth
@@ -256,6 +258,7 @@ download() {
256258
}
257259

258260
play_episode() {
261+
[ "$log_episode" = 1 ] && [ "$player_function" != "debug" ] && [ "$player_function" != "download" ] && command -v logger >/dev/null && logger -t ani-cli "${allanime_title}${ep_no}"
259262
[ "$skip_intro" = 1 ] && skip_flag="$(ani-skip -q "$mal_id" -e "$ep_no")"
260263
[ -z "$episode" ] && get_episode_url
261264
# shellcheck disable=SC2086
@@ -327,6 +330,7 @@ allanime_base="allanime.day"
327330
allanime_api="https://api.${allanime_base}"
328331
mode="${ANI_CLI_MODE:-sub}"
329332
download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
333+
log_episode="${ANI_CLI_LOG:-1}"
330334
quality="${ANI_CLI_QUALITY:-best}"
331335
case "$(uname -a)" in
332336
*Darwin*) player_function="$(where_iina)" ;; # mac OS
@@ -386,6 +390,14 @@ while [ $# -gt 0 ]; do
386390
: >"$histfile"
387391
exit 0
388392
;;
393+
-l | --logview)
394+
case "$(uname -s)" in
395+
Darwin*) log show --predicate 'process == "logger"' ;;
396+
Linux*) journalctl -t ani-cli ;;
397+
*) die "Logger not implemented for your platform" ;;
398+
esac
399+
exit 0
400+
;;
389401
-V | --version) version_info ;;
390402
-h | --help) help_info ;;
391403
-e | --episode | -r | --range)

ani-cli.1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Download episode.
2828
\fB\-D | --delete\fR
2929
Delete history.
3030
.TP
31+
\fB\-l | --logview\fR
32+
Show logs.
33+
.TP
3134
\fB\-h | --help\fR
3235
Show summary of options.
3336
.TP
@@ -86,6 +89,9 @@ Sets the player ani-cli uses. Can be debug (print links), download (equivalent t
8689
\fBANI_CLI_EXTERNAL_MENU\fR
8790
Controls the frontend of ani-cli. Can be 0 (uses fzf) or 1 (uses rofi dmenu). Default is 0.
8891
.TP
92+
\fBANI_CLI_LOG_EPISODE\fR
93+
Controls the logging feature for playback. Can be 1(logs) or 0(doesn't log). Default is 1.
94+
.TP
8995
\fBANI_CLI_MULTI_SELECTION\fR
9096
Controls the multi flag for the chosen frontend. Default is -m for fzf and --multi-select for rofi dmenu.
9197
.TP

0 commit comments

Comments
 (0)