LOGGER()

All functions > METADATA > LOGGER()

Logs the calls of a prepared statement to a sink, row by row, after each response is sent.

Signatures

Returns: A logger the serving engine runs on every call of the statement

LOGGER(
  ON prepared_statement
  [ WHERE condition ]
  [ EXCLUDE ( column, ... ) ]
  TO sink
)
column: feature [ [field] ... ] → LOGGER
ParameterTypeRequiredDescription
prepared_statementFEATUREYesA PREPARED_STATEMENT feature: its inputs, its output and its CAPTURE features are logged
sinkSINKYesWhere the rows go: a SINK feature, or SINK('<dsn>') inline. Cold sinks only (files, object stores, stdout://): Redis, Postgres and MySQL are refused
columnFEATUREYesAn input, the output, a captured feature, or a field path of a ROW one (SCORE[embedding]), left out of the log
conditionBOOLEANYesKeeps a row when TRUE; reads only the statement's inputs, output and captures. Failed calls are always logged

Notes

  • Each row holds CALL_ID, CALL_INDEX, CALL_TIME, CALL_DETAILS, then the statement's inputs, output and captures
  • INCLUDE and COLUMNS are refused: log more features with CAPTURE (...) in the prepared statement
  • A logger never changes its statement: it runs after the response, on the call's own row
  • ON, WHERE, EXCLUDE and TO come in this order; LOGGER(statement TO sink ...) is refused
  • A logger writes cold sinks only (files, object stores, stdout://): TO a Redis, PostgreSQL or MySQL sink is refused

See also

Examples

Log half the calls of a prepared statement, without the model name

FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.LOGGING.SCORE_LOGGER AS
LOGGER(
    ON FM.TUTORIALS.LOGGING.SCORE_PS
    WHERE HASH01('log/' || FM.TUTORIALS.LOGGING.USER_ID::VARCHAR) <.6 0.5
    EXCLUDE (FM.TUTORIALS.LOGGING.SCORE[model])
    TO FM.TUTORIALS.LOGGING.ML_LOGS
);
Result
feature_name VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.LOGGING.SCORE_LOGGERCREATEDFeature created as not exists