public function test_get_logs()
 {
     $x = new cs_webdblogger($this->dbObj, __CLASS__);
     // create some logs to search through.
     //		$x->log_by_class(__METHOD__, "error");
     $createRecords = array('MAIN' => array('first', 'second', 'third', 'fourth'), 'xxx' => array('fifth', 'sixth'), 'error' => array('seventh'), 'another' => array('EigTh'));
     $totalRecords = 0;
     $testRecords = array();
     $byClass = array();
     foreach ($createRecords as $class => $list) {
         foreach ($list as $details) {
             $id = $x->log_by_class($details, $class);
             $this->assertTrue(is_numeric($id));
             $testRecords[$id] = $details;
             if (isset($byClass[$class])) {
                 $byClass[$class]++;
             } else {
                 $byClass[$class] = 1;
             }
             $totalRecords++;
         }
     }
     foreach (array_keys($createRecords) as $class) {
         $theLogs = $x->get_logs($class);
         $this->assertEquals(count($createRecords[$class]), count($theLogs), "Failed to find logs that match '" . $class . "'... " . ToolBox::debug_print($theLogs));
     }
     //		$data = $x->get_logs(null);
     //
     //		$this->assertEquals(1, count($data), ToolBox::debug_print($data,1));
     //
     //		$this->assertEquals(1, count($x->get_logs('test')));
 }
 public function handle_new_record($type, $name, array $extraData = null)
 {
     if (is_null($extraData) || !is_array($extraData)) {
         $extraData = array();
     }
     $extraData['character_id'] = $this->characterId;
     $log = new cs_webdblogger($this->dbObj, "Character");
     switch ($type) {
         case Weapon::sheetIdPrefix:
             $x = new Weapon();
             $extraData['weapon_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case Armor::sheetIdPrefix:
             $x = new Armor();
             $extraData['armor_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case SpecialAbility::sheetIdPrefix:
             $x = new SpecialAbility();
             $extraData['special_ability_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case Gear::sheetIdPrefix:
             $x = new Gear();
             $extraData['gear_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case Skill::sheetIdPrefix:
             $x = new Skill();
             $extraData['skill_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         default:
             $details = __METHOD__ . ": invalid type (" . $type . ")";
             $log->log_by_class($details, "exception in code");
             throw new InvalidArgumentException($details);
     }
     $details = "New record, type=(" . $type . "), name=(" . $name . ")";
     if (is_array($details) && count($extraData) > 0) {
         $details .= implode(", ", $extraData);
     }
     $log->log_by_class($details, "create");
     return $result;
 }