;
; Asterisk Channel Event Logging (CEL) - Custom Sqlite3 Backend
;

; This is the configuration file for the customizable Sqlite3 backend for CEL
; logging.
;
; Legacy vs Advanced Mappings
;
; Legacy mappings are those that are defined using dialplan functions like
; CALLERID and CHANNEL and require a VERY expensive function replacement
; process at runtime for every record output.
;
; Advanced mappings are those that are defined by a simple list of field names
; and uses significantly less resources at runtime.
;
;
; Each category in this file represents a separate Sqlite3 database file.
; A filename that starts with a forward-slash '/' will be treated as an absolute
; path name.  If it doesn't, it must be a file name with no directory separators
; which will be placed in the /var/log/asterisk directory.  If the database
; file doesn't already exist, it will be created.
;
; Previous versions of Asterisk limited the output to a single database file
; named "master" which was shared with CDR Sqlite3 logging.  That is no longer
; the case.
;
;
; There are several "special" variables created by this module that can be used
; in a mapping, both legacy and advanced:
;
;    eventtype   - The name of the CEL event.
;    eventtime   - The timestamp of the CEL event.
;    eventenum   - Like eventtype but is "USER_DEFINED" for a user defined event.
;    userdeftype - User defined event type name from CELGenUserEvent().
;    eventextra  - Extra data included with this CEL event, typically along with
;                  an event of type USER_DEFINED from CELGenUserEvent().
;    BRIDGEPEER  - Bridged peer channel name at the time of the CEL event.
;                  CHANNEL(peer) could also be used.
;
; Legacy Mappings
;
; Within a legacy mapping, use the CALLERID() and CHANNEL() functions or
; the special variables above to retrieve values from the CEL event.
;
; NOTE: If your legacy mapping uses only those two functions and the special
; variables, the module will attempt to strip the functions and create a much
; faster advanced mapping for it. However, we urge you to create a real advanced
; mapping and not rely on this process. If the mapping contains something not
; recognized it will go the slower legacy route.
;
;
;[cel_master]
;table = cel             ; The name of the table in the database into which records
                         ; are to be written.  If the table doesn't already exist,
                         ; it will be created.

;columns = eventtype, eventtime, cidname, cidnum, cidani, cidrdnis, ciddnid, context, exten, channame, appname, appdata, amaflags, accountcode, uniqueid, userfield, peer, userdeftype, eventextra
    ; The column names to receive the fields.  If the table doesn't already exist,
    ; it will be created with these columns.  If the table does exist, this list
    ; MUST match the existing columns or the config will fail to load.
    ; The column names do NOT have to match the field names however.

values = '${eventtype}','${eventtime}','${CALLERID(name)}','${CALLERID(num)}','${CALLERID(ANI)}','${CALLERID(RDNIS)}','${CALLERID(DNID)}','${CHANNEL(context)}','${CHANNEL(exten)}','${CHANNEL(channame)}','${CHANNEL(appname)}','${CHANNEL(appdata)}','${CHANNEL(amaflags)}','${CHANNEL(accountcode)}','${CHANNEL(uniqueid)}','${CHANNEL(userfield)}','${BRIDGEPEER}','${userdeftype}','${eventextra}'
    ; The list of fields to write into the columns.
    ; Each field MUST be enclosed in single-quotes and the fields separated
    ; by commas.  Additionally, the number of fields specified MUST match the
    ; number of columns or the config will fail to load.

;busy_timeout = 1000    ; The number of milliseconds to wait for a database operation
                        ; to complete before an error is returned.

;
; Advanced Mappings
;
;[cdr_advanced]
;table = cel             ; The name of the table in the database into which records
                         ; are to be written.  If the table doesn't already exist,
                         ; it will be created.

;columns = eventtype, literal, eventtime, cidname, cidnum, cidani, cidrdnis, ciddnid, context, exten, channame, appname, appdata, amaflags, accountcode, uniqueid, userfield, peer, userdeftype, eventextra
    ; The column names to receive the fields.  If the table doesn't already exist,
    ; it will be created with these columns.  If the table does exist, this list
    ; MUST match the existing columns or the config will fail to load.
    ; The column names do NOT have to match the field names however.

;fields = eventtype, "some literal", eventtime, name, num, ani, rdnis, dnid, context, exten, channame, appname, appdata, amaflags, accountcode, uniqueid, userfield, peer, userdeftype, eventextra
    ; The "fields" parameter differentiates this mapping as an Advanced one
    ; as opposed to "values" used above.
    ;
    ; This is the list of fields to include in the record. The field names are the
    ; same as in the legacy mapping but without any enclosing dialplan functions or
    ; quotes. You can specify literals to be placed in the output record by
    ; double-quoting them. There is also some special notation available in the
    ; form of "qualifiers". A qualifier is a list of tags, separated by the '^'
    ; character and placed directly after the field name and enclosed in parentheses.
    ;
    ; The default output format for the "EventTime" timestamp field is the "%Y-%m-%d %T"
    ; strftime string format however you can also format the field as an int64 or a
    ; float: `eventtime(int64)` or `eventtime(float)`.
    ;
    ; Unlike CDRs, the "amaflags" field is output as its numerical value by default
    ; for historical reasons.  You can output it as its friendly string with
    ; `amaflags(amaflags)`. This will print "DOCUMENTATION" instead of "3" for instance.
    ;
    ; If you need to combine flags, use the caret '^' symbol: `eventtime(int64^noquote)`
    ;
    ; Final notes about "fields":
    ;    Field names and qualifiers aren't case sensitive.
    ;    You MUST use commas to separate the fields.
    ;    You MUST use double-quotes to indicate literal fields.
    ;    Whitespace in "fields" is ignored except in literals.

;busy_timeout = 1000    ; The number of milliseconds to wait for a database operation
                        ; to complete before an error is returned.

