DDB_TYPE_STRING, // GUID because setPKeyType == DB_TOKEN LOG_FILE => DDB_TYPE_STRING, LOG_METHOD => DDB_TYPE_STRING, LOG_LINE => DDB_TYPE_NUMBER, LOG_CLASS => DDB_TYPE_STRING, LOG_LEVEL => DDB_TYPE_STRING, LOG_MESSAGE => DDB_TYPE_STRING, LOG_STACK_TRACE => DDB_TYPE_LIST, DB_STATUS => DDB_TYPE_STRING, DB_HISTORY => DDB_TYPE_LIST, LOG_IS_EVENT => DDB_TYPE_BOOLEAN, LOG_EVENT_GUID => DDB_TYPE_STRING, LOG_CREATED => DDB_TYPE_NUMBER ]; public $fieldTypes = [ DB_PKEY => DATA_TYPE_STRING, // guid LOG_FILE => DATA_TYPE_STRING, LOG_METHOD => DATA_TYPE_STRING, LOG_LINE => DATA_TYPE_INTEGER, LOG_CLASS => DATA_TYPE_STRING, LOG_LEVEL => DATA_TYPE_STRING, LOG_MESSAGE => DATA_TYPE_STRING, LOG_STACK_TRACE => DATA_TYPE_ARRAY, DB_STATUS => DATA_TYPE_STRING, DB_TIMER => DATA_TYPE_DOUBLE, DB_HISTORY => DATA_TYPE_ARRAY, LOG_IS_EVENT => DATA_TYPE_BOOL, LOG_EVENT_GUID => DATA_TYPE_STRING, LOG_CREATED => DATA_TYPE_INTEGER ]; // in the ddb world, this is the primary composite key for this table public $indexes = [ DB_PKEY => DDB_INDEX_HASH, LOG_CREATED => DDB_INDEX_RANGE ]; /* * declaring global and local secondary indexes: * * Limit: 5 of each * * General Format: * --------------- * Each tuple, up to the limit, is a record that contains the following array structure: * * [[ * 'name' => INDEX_NAME, // REQUIRED * 'indexes' => [ KEY_NAME => HASH {, KEY_NAME => RANGE } ], // REQUIRED * 'projectionType' => { KEYS_ONLY | INCLUDE | ALL }, // REQUIRED * 'nka' => { [ list of one or more non-key attributes !>20 ] }, // REQUIRED if projection = INCLUDE * 'throughput' => [ 'rcu' => , 'wcu' => ] // REQUIRED for GLOBAL only * ],....]; * * secondary index keys must use the key literals as shown above. ('name', 'indexes', 'projectionType', etc.) * */ public $globalIndexes = array( [ // this creates a partition key based on the log level (fatal, warn, debug, etc.) with a sort key // based on the method (the class method that created the log event). // query example: give me all fatal errors // give me all warnings generate by the method: _fetchData() // Since the base keys (id, date) are projected onto this index, I am (awaiting testing) assuming // that you could also range your query based on the creation date. STRING_NAME => 'index_log_level', STRING_INDEXES => [ LOG_LEVEL => DDB_INDEX_HASH, LOG_METHOD => DDB_INDEX_RANGE ], DDB_STRING_PT => DDB_PT_ALL, STRING_THROUGHPUT => [ CONFIG_DATABASE_READ_CAPACITY_UNITS => 100, CONFIG_DATABASE_WRITE_CAPACITY_UNITS => 100 ] ], [ // lets add a second global index: key will be the created date, and the sort will be the error level // this will allow us to answer queries like: // give me all errors in the last hour // give me all fatal errors for January STRING_NAME => 'index_log_created', STRING_INDEXES => [ LOG_CREATED => DDB_INDEX_HASH, LOG_LEVEL => DDB_INDEX_RANGE ], DDB_STRING_PT => DDB_PT_INCLUDE, DDB_STRING_NON_KEY_ATTRIBUTE => [ LOG_FILE, LOG_CLASS, LOG_METHOD, LOG_LINE ], STRING_THROUGHPUT => [ CONFIG_DATABASE_READ_CAPACITY_UNITS => 100, CONFIG_DATABASE_WRITE_CAPACITY_UNITS => 100 ] ] ); public $localIndexes = array( [ // create secondary index using the log-level as the range value making the assumption that the // base index hash will be used as the local secondary hash STRING_NAME => 'index_sec_level', STRING_INDEXES => [ DB_PKEY => DDB_INDEX_HASH, LOG_LEVEL => DDB_INDEX_RANGE ], DDB_STRING_PT => DDB_PT_ALL ] ); public $exposedFields = null; // list of fields exposed to clients public $cacheMap = null; // k->v paired array mapping fields -> cachedField Names public $binFields = null; // binary fields that have to be encoded // these fields aren't used in DDB, but are used in mongo, so are here only for code-compatibility public $uniqueIndexes = null; public $sparseIndexes = null; public $subCollections = null; /** * __construct() -- public method * * we have a constructor to register the destructor. * * @author mike@givingassistant.org * @version 1.0 * * HISTORY: * ======== * 06-07-17 mks original coding * */ public function __construct() { register_shutdown_function([$this, STRING_DESTRUCTOR]); } /** * __clone() -- private function * * Silently disallows cloning of the object * * @author mike@givingassistant.org * @version 1.0 * * @return null * * HISTORY: * ======== * 06-07-17 mks original coding * */ private function __clone() { return(null); } /** * __destruct() -- public function * * As of PHP 5.3.10 destructors are not run on shutdown caused by fatal errors. * * The destructor is registered as a shut-down function in the constructor -- so any recovery * efforts should go in this method. * * @author mike@givingassistant.org * @version 1.0 * * HISTORY: * ======== * 06-07-17 mks original coding * */ public function __destruct() { ; } }