diff --git a/Jellyfin.Plugin.SmartPlaylist/ScheduledTasks/GeneratePlaylist.cs b/Jellyfin.Plugin.SmartPlaylist/ScheduledTasks/GeneratePlaylist.cs index ca85c8d..99f1796 100644 --- a/Jellyfin.Plugin.SmartPlaylist/ScheduledTasks/GeneratePlaylist.cs +++ b/Jellyfin.Plugin.SmartPlaylist/ScheduledTasks/GeneratePlaylist.cs @@ -98,6 +98,24 @@ namespace Jellyfin.Plugin.SmartPlaylist.ScheduledTasks { List results = new List(); Expression expression = new Parser(StringTokenStream.generate(smartPlaylist.Program)).parse(); // parse here, so that we don't repeat the work for each item Executor executor = new Executor(new DefaultEnvironment()); + + executor.builtins["logd"] = (x) => { + _logger.LogDebug(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray()); + return Lisp_Boolean.TRUE; + }; + executor.builtins["logi"] = (x) => { + _logger.LogInformation(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray()); + return Lisp_Boolean.TRUE; + }; + executor.builtins["logw"] = (x) => { + _logger.LogWarning(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray()); + return Lisp_Boolean.TRUE; + }; + executor.builtins["loge"] = (x) => { + _logger.LogError(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray()); + return Lisp_Boolean.TRUE; + }; + executor.environment.Set("user", Lisp_Object.FromBase(user)); if (Plugin.Instance is not null) { executor.eval(Plugin.Instance.Configuration.InitialProgram); diff --git a/README.md b/README.md index bbb58f8..97f722a 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ the items by name you could use the following program: - **is-type**: matches the type of item look at [BaseItemKind.cs](https://github.com/jellyfin/jellyfin/blob/master/Jellyfin.Data/Enums/BaseItemKind.cs) for a list of items. The plugin has enabled support for `Audio, MusicAlbum, Playlist` (`(is-type "Audio")`) +- **log[diwe]**: write to the logger with the respective levels (`debug`, `information`, `warning`, `error`). + Takes the same arguments as `Logger.LogInformation(...)`. ### Filename