Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current year in the name of the access.log file #21

Open
ookris opened this issue Oct 28, 2018 · 1 comment
Open

Current year in the name of the access.log file #21

ookris opened this issue Oct 28, 2018 · 1 comment

Comments

@ookris
Copy link

ookris commented Oct 28, 2018

Hi
Is it possible to add the current year to the name of the generated * .log file, e.g. 2018_access.log? And for more advanced users, you could add the option to generate a file in a week or month.
It would cause that the log file would not get too large.

@ookris
Copy link
Author

ookris commented Nov 23, 2018

Solution

open /conf/metadata.php, add

$meta['accesslog_annual'] = array('onoff');

open /conf/default.php, add

$conf['accesslog_annual'] = 0;

open /lang/en/settings.php, add

$lang['accesslog_annual'] = 'Enable the annual log file? This will add the current year to the log file name e.g. <code>2018-access.log</code>';

open action.php, find

// determine log, relative paths resolve to meta dir
        $dir = dirname($this->getConf('accesslog'));
        $log = basename($this->getConf('accesslog'));
        if($dir == '.' || $dir == '' || !is_dir($dir)){
            $dir = fullpath($conf['metadir'].'/'.$dir);
        }
        return io_saveFile("$dir/$log", $logline, true);

change to

// determine log, relative paths resolve to meta dir
        $year = date("Y");
        $dir = dirname($this->getConf('accesslog'));
        if($this->getConf('accesslog_annual') == 1) {
            $log = basename($year . '-' . $this->getConf('accesslog'));
        } else {
            $log = basename($this->getConf('accesslog'));
        }
        if($dir == '.' || $dir == '' || !is_dir($dir)){
            $dir = fullpath($conf['metadir'].'/'.$dir);
        }

        return io_saveFile("$dir/$log", $logline, true);

Save all files and send to the server. Open the settings page and change the new option.

zrzut ekranu 2018-11-23 o 20 26 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant