Completed
Push — master ( 52c0e0...e30226 )
by Morris
58:43 queued 44:07
created
lib/private/Log/Rotate.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -32,23 +32,23 @@
 block discarded – undo
32 32
  * location and manage that with your own tools.
33 33
  */
34 34
 class Rotate extends \OC\BackgroundJob\Job {
35
-	private $max_log_size;
36
-	public function run($dummy) {
37
-		$systemConfig = \OC::$server->getSystemConfig();
38
-		$logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
39
-		$this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
40
-		if ($this->max_log_size) {
41
-			$filesize = @filesize($logFile);
42
-			if ($filesize >= $this->max_log_size) {
43
-				$this->rotate($logFile);
44
-			}
45
-		}
46
-	}
35
+    private $max_log_size;
36
+    public function run($dummy) {
37
+        $systemConfig = \OC::$server->getSystemConfig();
38
+        $logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
39
+        $this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
40
+        if ($this->max_log_size) {
41
+            $filesize = @filesize($logFile);
42
+            if ($filesize >= $this->max_log_size) {
43
+                $this->rotate($logFile);
44
+            }
45
+        }
46
+    }
47 47
 
48
-	protected function rotate($logfile) {
49
-		$rotatedLogfile = $logfile.'.1';
50
-		rename($logfile, $rotatedLogfile);
51
-		$msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"';
52
-		\OCP\Util::writeLog(Rotate::class, $msg, \OCP\Util::WARN);
53
-	}
48
+    protected function rotate($logfile) {
49
+        $rotatedLogfile = $logfile.'.1';
50
+        rename($logfile, $rotatedLogfile);
51
+        $msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"';
52
+        \OCP\Util::writeLog(Rotate::class, $msg, \OCP\Util::WARN);
53
+    }
54 54
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	private $max_log_size;
36 36
 	public function run($dummy) {
37 37
 		$systemConfig = \OC::$server->getSystemConfig();
38
-		$logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
38
+		$logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log');
39 39
 		$this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
40 40
 		if ($this->max_log_size) {
41 41
 			$filesize = @filesize($logFile);
Please login to merge, or discard this patch.
core/Command/Log/File.php 2 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -36,123 +36,123 @@
 block discarded – undo
36 36
 
37 37
 class File extends Command implements Completion\CompletionAwareInterface {
38 38
 
39
-	/** @var IConfig */
40
-	protected $config;
41
-
42
-	public function __construct(IConfig $config) {
43
-		$this->config = $config;
44
-		parent::__construct();
45
-	}
46
-
47
-	protected function configure() {
48
-		$this
49
-			->setName('log:file')
50
-			->setDescription('manipulate logging backend')
51
-			->addOption(
52
-				'enable',
53
-				null,
54
-				InputOption::VALUE_NONE,
55
-				'enable this logging backend'
56
-			)
57
-			->addOption(
58
-				'file',
59
-				null,
60
-				InputOption::VALUE_REQUIRED,
61
-				'set the log file path'
62
-			)
63
-			->addOption(
64
-				'rotate-size',
65
-				null,
66
-				InputOption::VALUE_REQUIRED,
67
-				'set the file size for log rotation, 0 = disabled'
68
-			)
69
-		;
70
-	}
71
-
72
-	protected function execute(InputInterface $input, OutputInterface $output) {
73
-		$toBeSet = [];
74
-
75
-		if ($input->getOption('enable')) {
76
-			$toBeSet['log_type'] = 'file';
77
-		}
78
-
79
-		if ($file = $input->getOption('file')) {
80
-			$toBeSet['logfile'] = $file;
81
-		}
82
-
83
-		if (($rotateSize = $input->getOption('rotate-size')) !== null) {
84
-			$rotateSize = \OCP\Util::computerFileSize($rotateSize);
85
-			$this->validateRotateSize($rotateSize);
86
-			$toBeSet['log_rotate_size'] = $rotateSize;
87
-		}
88
-
89
-		// set config
90
-		foreach ($toBeSet as $option => $value) {
91
-			$this->config->setSystemValue($option, $value);
92
-		}
93
-
94
-		// display config
95
-		// TODO: Drop backwards compatibility for config in the future
96
-		$logType = $this->config->getSystemValue('log_type', 'file');
97
-		if ($logType === 'file' || $logType === 'owncloud') {
98
-			$enabledText = 'enabled';
99
-		} else {
100
-			$enabledText = 'disabled';
101
-		}
102
-		$output->writeln('Log backend file: '.$enabledText);
103
-
104
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
105
-		$defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log';
106
-		$output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile));
107
-
108
-		$rotateSize = $this->config->getSystemValue('log_rotate_size', 100*1024*1024);
109
-		if ($rotateSize) {
110
-			$rotateString = \OCP\Util::humanFileSize($rotateSize);
111
-		} else {
112
-			$rotateString = 'disabled';
113
-		}
114
-		$output->writeln('Rotate at: '.$rotateString);
115
-	}
116
-
117
-	/**
118
-	 * @param mixed $rotateSize
119
-	 * @throws \InvalidArgumentException
120
-	 */
121
-	protected function validateRotateSize(&$rotateSize) {
122
-		if ($rotateSize === false) {
123
-			throw new \InvalidArgumentException('Error parsing log rotation file size');
124
-		}
125
-		$rotateSize = (int) $rotateSize;
126
-		if ($rotateSize < 0) {
127
-			throw new \InvalidArgumentException('Log rotation file size must be non-negative');
128
-		}
129
-	}
130
-
131
-	/**
132
-	 * @param string $optionName
133
-	 * @param CompletionContext $context
134
-	 * @return string[]
135
-	 */
136
-	public function completeOptionValues($optionName, CompletionContext $context) {
137
-		if ($optionName === 'file') {
138
-			$helper = new ShellPathCompletion(
139
-				$this->getName(),
140
-				'file',
141
-				Completion::TYPE_OPTION
142
-			);
143
-			return $helper->run();
144
-		} else if ($optionName === 'rotate-size') {
145
-			return [0];
146
-		}
147
-		return [];
148
-	}
149
-
150
-	/**
151
-	 * @param string $argumentName
152
-	 * @param CompletionContext $context
153
-	 * @return string[]
154
-	 */
155
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
156
-		return [];
157
-	}
39
+    /** @var IConfig */
40
+    protected $config;
41
+
42
+    public function __construct(IConfig $config) {
43
+        $this->config = $config;
44
+        parent::__construct();
45
+    }
46
+
47
+    protected function configure() {
48
+        $this
49
+            ->setName('log:file')
50
+            ->setDescription('manipulate logging backend')
51
+            ->addOption(
52
+                'enable',
53
+                null,
54
+                InputOption::VALUE_NONE,
55
+                'enable this logging backend'
56
+            )
57
+            ->addOption(
58
+                'file',
59
+                null,
60
+                InputOption::VALUE_REQUIRED,
61
+                'set the log file path'
62
+            )
63
+            ->addOption(
64
+                'rotate-size',
65
+                null,
66
+                InputOption::VALUE_REQUIRED,
67
+                'set the file size for log rotation, 0 = disabled'
68
+            )
69
+        ;
70
+    }
71
+
72
+    protected function execute(InputInterface $input, OutputInterface $output) {
73
+        $toBeSet = [];
74
+
75
+        if ($input->getOption('enable')) {
76
+            $toBeSet['log_type'] = 'file';
77
+        }
78
+
79
+        if ($file = $input->getOption('file')) {
80
+            $toBeSet['logfile'] = $file;
81
+        }
82
+
83
+        if (($rotateSize = $input->getOption('rotate-size')) !== null) {
84
+            $rotateSize = \OCP\Util::computerFileSize($rotateSize);
85
+            $this->validateRotateSize($rotateSize);
86
+            $toBeSet['log_rotate_size'] = $rotateSize;
87
+        }
88
+
89
+        // set config
90
+        foreach ($toBeSet as $option => $value) {
91
+            $this->config->setSystemValue($option, $value);
92
+        }
93
+
94
+        // display config
95
+        // TODO: Drop backwards compatibility for config in the future
96
+        $logType = $this->config->getSystemValue('log_type', 'file');
97
+        if ($logType === 'file' || $logType === 'owncloud') {
98
+            $enabledText = 'enabled';
99
+        } else {
100
+            $enabledText = 'disabled';
101
+        }
102
+        $output->writeln('Log backend file: '.$enabledText);
103
+
104
+        $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
105
+        $defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log';
106
+        $output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile));
107
+
108
+        $rotateSize = $this->config->getSystemValue('log_rotate_size', 100*1024*1024);
109
+        if ($rotateSize) {
110
+            $rotateString = \OCP\Util::humanFileSize($rotateSize);
111
+        } else {
112
+            $rotateString = 'disabled';
113
+        }
114
+        $output->writeln('Rotate at: '.$rotateString);
115
+    }
116
+
117
+    /**
118
+     * @param mixed $rotateSize
119
+     * @throws \InvalidArgumentException
120
+     */
121
+    protected function validateRotateSize(&$rotateSize) {
122
+        if ($rotateSize === false) {
123
+            throw new \InvalidArgumentException('Error parsing log rotation file size');
124
+        }
125
+        $rotateSize = (int) $rotateSize;
126
+        if ($rotateSize < 0) {
127
+            throw new \InvalidArgumentException('Log rotation file size must be non-negative');
128
+        }
129
+    }
130
+
131
+    /**
132
+     * @param string $optionName
133
+     * @param CompletionContext $context
134
+     * @return string[]
135
+     */
136
+    public function completeOptionValues($optionName, CompletionContext $context) {
137
+        if ($optionName === 'file') {
138
+            $helper = new ShellPathCompletion(
139
+                $this->getName(),
140
+                'file',
141
+                Completion::TYPE_OPTION
142
+            );
143
+            return $helper->run();
144
+        } else if ($optionName === 'rotate-size') {
145
+            return [0];
146
+        }
147
+        return [];
148
+    }
149
+
150
+    /**
151
+     * @param string $argumentName
152
+     * @param CompletionContext $context
153
+     * @return string[]
154
+     */
155
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
156
+        return [];
157
+    }
158 158
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 		$defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log';
106 106
 		$output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile));
107 107
 
108
-		$rotateSize = $this->config->getSystemValue('log_rotate_size', 100*1024*1024);
108
+		$rotateSize = $this->config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
109 109
 		if ($rotateSize) {
110 110
 			$rotateString = \OCP\Util::humanFileSize($rotateSize);
111 111
 		} else {
Please login to merge, or discard this patch.