z (zotonic_core v1.0.0-rc.17)

Interfaces for command line utilities in zotonic_launcher, some easy shortcuts and error logging functions.

Summary

Functions

Return a new context

(Re)make all erlang source modules with the supplied compile options. Do not reset the caches.

Log a debug message to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zDebug</tt> macro.

Echo and return a debugging value. This is useful for adding debug anywhere in the code, as the passed argument is also returned. Example: <tt>foo( ?DEBUG(Arg) )</tt> will add Arg as a notice to the logs and still call <tt>foo(Arg)</tt>.

Return the complete dispatch information for the site.

Shell command: dispatch a path, return trace

Dispatch an URL - find matching site and dispatch the path

Return the current environment

Log a error to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zError</tt> macro.

Log a fatal error to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zError</tt> macro.

Reset all caches, reload the dispatch rules and rescan all modules.

Log an informational message to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zInfo</tt> macro.

Check if a module of a site is enabled.

Reload all changed Erlang modules

Reload an Erlang module

m()

(Re)make all erlang source modules and reset the caches.

Send a notification to the first observer and return the result.

Send an async notification.

Log a notice to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zNotice</tt> macro.

Open a site in Chrome or the default browser(macOS)

Open a site in a new fresh Chrome

Reindex all sites, find new files.

Full restart of Zotonic

Restart a site

Set a runtime config value. This is useful to enable or disable certain runtime features without restarting Zotonic.

Shell commands: stop a site

Shell commands: start a site

Shell commands: stop a site

Start a site

Stop a site

Log a warning to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zWarning</tt> macro.

Types

context/0

-type context() ::
          #context{cowreq :: cowboy_req:req() | undefined,
                   cowenv :: cowboy_middleware:env() | undefined,
                   site :: atom(),
                   controller_module :: atom() | undefined,
                   client_id :: binary() | undefined,
                   client_topic :: mqtt_sessions:topic() | undefined,
                   routing_id :: binary() | undefined,
                   acl :: term() | admin | undefined,
                   acl_is_read_only :: boolean(),
                   user_id :: integer() | authenticated | undefined,
                   render_state :: undefined | z_render:render_state(),
                   db :: {atom(), atom()} | undefined,
                   dbc :: pid() | undefined,
                   language :: [atom()],
                   tz :: binary(),
                   props :: map(),
                   depcache :: pid() | atom(),
                   dispatcher :: pid() | atom(),
                   template_server :: pid() | atom(),
                   scomp_server :: pid() | atom(),
                   dropbox_server :: pid() | atom(),
                   pivot_server :: pid() | atom(),
                   module_indexer :: pid() | atom(),
                   translation_table :: atom()}.

environment/0

-type environment() :: development | test | acceptance | production | education | backup.

qvalue/0

-type qvalue() ::
          binary() |
          string() |
          #upload{filename :: binary() | undefined,
                  tmpfile :: file:filename_all() | undefined,
                  tmpmonitor :: undefined | pid(),
                  data :: binary() | undefined,
                  mime :: binary() | undefined} |
          term().

severity/0

-type severity() :: debug | info | notice | warning | error | fatal.

trans/0

-type trans() :: #trans{tr :: [{atom(), binary()}]}.

validation_error/0

-type validation_error() :: invalid | novalue | {script, iodata()} | novalidator | string().

Functions

c(Site)

-spec c(atom()) -> z:context().

Return a new context

compile()

(Re)make all erlang source modules with the supplied compile options. Do not reset the caches.

debug(Msg, Context)

Log a debug message to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zDebug</tt> macro.

debug(Msg, Meta, Context)

debug(Format, Args, Meta, Context)

debug_msg(Msg, Meta)

Echo and return a debugging value. This is useful for adding debug anywhere in the code, as the passed argument is also returned. Example: <tt>foo( ?DEBUG(Arg) )</tt> will add Arg as a notice to the logs and still call <tt>foo(Arg)</tt>.

dispatch_list(SiteOrContext)

Return the complete dispatch information for the site.

dispatch_path(Path, Site)

Shell command: dispatch a path, return trace

dispatch_url(Url)

Dispatch an URL - find matching site and dispatch the path

env(Site)

-spec env(Site :: atom()) -> environment().

Return the current environment

error(Msg, Context)

Log a error to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zError</tt> macro.

error(Msg, Meta, Context)

error(Format, Args, Meta, Context)

fatal(Msg, Context)

Log a fatal error to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zError</tt> macro.

fatal(Msg, Meta, Context)

fatal(Format, Args, Meta, Context)

flush()

-spec flush() -> ok.

Reset all caches, reload the dispatch rules and rescan all modules.

flush(Site)

-spec flush(atom() | z:context()) -> ok.

info(Msg, Context)

Log an informational message to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zInfo</tt> macro.

info(Msg, Meta, Context)

info(Format, Args, Meta, Context)

is_module_enabled(Module, Site)

-spec is_module_enabled(Module :: atom(), Site :: atom()) -> boolean().

Check if a module of a site is enabled.

ld()

Reload all changed Erlang modules

ld(Module)

Reload an Erlang module

log(Level, Meta, Context)

-spec log(Level :: severity(), Meta :: proplists:proplist() | map(), Context :: z:context()) -> ok.

m()

(Re)make all erlang source modules and reset the caches.

n1(Msg, Site)

Send a notification to the first observer and return the result.

n(Msg, Site)

Send an async notification.

notice(Msg, Context)

Log a notice to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zNotice</tt> macro.

notice(Msg, Meta, Context)

notice(Format, Args, Meta, Context)

open(Site)

Open a site in Chrome or the default browser(macOS)

open_secure(Site)

Open a site in a new fresh Chrome

reindex()

Reindex all sites, find new files.

restart()

Full restart of Zotonic

restart(Site)

Restart a site

setconfig(_, Name, Value)

Set a runtime config value. This is useful to enable or disable certain runtime features without restarting Zotonic.

shell_restartsite(Site)

Shell commands: stop a site

shell_startsite(Site)

Shell commands: start a site

shell_stopsite(Site)

Shell commands: stop a site

start(Site)

Start a site

stop(Site)

Stop a site

warning(Msg, Context)

Log a warning to the logs and the database, with extra meta data. To add the current source location, use the <tt>?zWarning</tt> macro.

warning(Msg, Meta, Context)

warning(Format, Args, Meta, Context)