<commit_before><?php
/**
 * Created by PhpStorm.
 * User: budde
 * Date: 5/17/14
 * Time: 6:36 PM
 */

class UserSettingsEditLogPageElementImpl extends PageElementImpl{

    use DateTimeTrait;

    private $container;

    function __construct(BackendSingletonContainer $container)
    {
        $this->container = $container;
    }

    public function generateContent()
    {
        parent::generateContent();

        $log = $this->container->getLoggerInstance();
       // $log->log(uniqid("MSG"),pow(2,rand(0,3)), rand(0,1));
        $rows = "";
        foreach($l = $log->listLog() as $entry){
            /** @var $entry array */
            $t = $entry['time'];
            $dumpFile = isset($entry["dumpfile"])?"<a href='#'  data-id='$t' >&nbsp;</a>":"";
            $date = date('j-n-Y \k\l. H:i:s',$t);
            $rows = "
            <tr class='{$this->levelToString($entry['level'], true)}' >
                <td class='level' title='{$this->levelToString($entry['level'])}'> </td>
                <td>{$entry['message']}</td>
                <td class='dumpfile'>$dumpFile</td>
                <td class='date'>$date</td>
            </tr>".$rows;

        }
        $emptyClass = count($l)?"":"empty";
        $count = count($l);
        $output = "
        <table id='UserSettingsLogTable' class='$emptyClass'>
            $rows
            <tr class='empty_row'><td>Loggen er tom</td></tr>
        </table>
        <p id='LogInfoParagraph'>
        Der er registreret <i>$count</i> indgange.
        <a href='#' id='ClearLogLink'>Ryd loggen</a>.
        </p>
        ";



        return $output;



    }

    /**
     * @param String $level
     * @param bool $lowercase
     * @return String
     */
    private function levelToString($level, $lowercase = false)
    {
        if(!$lowercase){
            return strtoupper($this->levelToString($level, true));
        }

        switch($level){
            case Logger::LOG_LEVEL_ALERT:
                return "alert";
                break;
            case Logger::LOG_LEVEL_DEBUG:
                return "debug";
                break;
            case Logger::LOG_LEVEL_CRITICAL:
                return "critical";
                break;
            case Logger::LOG_LEVEL_EMERGENCY:
                return "emergency";
                break;
            case Logger::LOG_LEVEL_INFO:
                return "info";
                break;
            case Logger::LOG_LEVEL_NOTICE:<commit_msg>Fixed uppercase<commit_after><?php
/**
 * Created by PhpStorm.
 * User: budde
 * Date: 5/17/14
 * Time: 6:36 PM
 */

class UserSettingsEditLogPageElementImpl extends PageElementImpl{

    use DateTimeTrait;

    private $container;

    function __construct(BackendSingletonContainer $container)
    {
        $this->container = $container;
    }

    public function generateContent()
    {
        parent::generateContent();

        $log = $this->container->getLoggerInstance();
       // $log->log(uniqid("MSG"),pow(2,rand(0,3)), rand(0,1));
        $rows = "";
        foreach($l = $log->listLog() as $entry){
            /** @var $entry array */
            $t = $entry['time'];
            $dumpFile = isset($entry["dumpfile"])?"<a href='#'  data-id='$t' >&nbsp;</a>":"";
            $date = date('j-n-Y \k\l. H:i:s',$t);
            $rows = "
            <tr class='{$this->levelToString($entry['level'], true)}' >
                <td class='level' title='{$this->levelToString($entry['level'])}'> </td>
                <td>{$entry['message']}</td>
                <td class='dumpfile'>$dumpFile</td>
                <td class='date'>$date</td>
            </tr>".$rows;

        }
        $emptyClass = count($l)?"":"empty";
        $count = count($l);
        $output = "
        <table id='UserSettingsLogTable' class='$emptyClass'>
            $rows
            <tr class='empty_row'><td>Loggen er tom</td></tr>
        </table>
        <p id='LogInfoParagraph'>
        Der er registreret <i>$count</i> indgange.
        <a href='#' id='ClearLogLink'>Ryd loggen</a>.
        </p>
        ";



        return $output;



    }

    /**
     * @param String $level
     * @param bool $lowercase
     * @return String
     */
    private function levelToString($level, $lowercase = false)
    {
        if(!$lowercase){
            return ucwords($this->levelToString($level, true));
        }

        switch($level){
            case Logger::LOG_LEVEL_ALERT:
                return "alert";
                break;
            case Logger::LOG_LEVEL_DEBUG:
                return "debug";
                break;
            case Logger::LOG_LEVEL_CRITICAL:
                return "critical";
                break;
            case Logger::LOG_LEVEL_EMERGENCY:
                return "emergency";
                break;
            case Logger::LOG_LEVEL_INFO:
                return "info";
                break;
            case Logger::LOG_LEVEL_NOTICE:
{'fraction_non_alphanumeric': 0.1603563474387528, 'fraction_numerical': 0.005264223527029763, 'mean_word_length': 1.7941176470588236, 'pattern_counts': {'":': 4, '<': 53, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5825118', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1442, 'n_words': 276}