5454use OCP \Util ;
5555
5656class SMB extends StorageAdapter {
57+ /** @var bool */
58+ protected $ logActive ;
59+
5760 /**
5861 * @var IServer
5962 */
@@ -75,6 +78,11 @@ class SMB extends StorageAdapter {
7578 protected $ statCache ;
7679
7780 public function __construct ($ params ) {
81+ // log switch might be set already (from a subclass), so don't change it.
82+ if (!isset ($ this ->logActive )) {
83+ $ this ->logActive = \OC ::$ server ->getConfig ()->getSystemValue ('smb.logging.enable ' , false ) === true ;
84+ }
85+
7886 $ loggedParams = $ params ;
7987 // remove password from log if it is set
8088 if (!empty ($ loggedParams ['password ' ])) {
@@ -743,7 +751,7 @@ public function test() {
743751 * @param string $from
744752 */
745753 private function log ($ message , $ level = Util::DEBUG , $ from = 'smb ' ) {
746- if (\ OC :: $ server -> getConfig ()-> getSystemValue ( ' smb.logging.enable ' , false ) === true ) {
754+ if ($ this -> logActive ) {
747755 Util::writeLog ($ from , $ message , $ level );
748756 }
749757 }
@@ -757,7 +765,7 @@ private function log($message, $level = Util::DEBUG, $from = 'smb') {
757765 * @return mixed
758766 */
759767 private function leave ($ function , $ result ) {
760- if (\ OC :: $ server -> getConfig ()-> getSystemValue ( ' smb.logging.enable ' , false ) === false ) {
768+ if (! $ this -> logActive ) {
761769 //don't bother building log strings
762770 return $ result ;
763771 } elseif ($ result === true ) {
@@ -780,7 +788,7 @@ private function leave($function, $result) {
780788 }
781789
782790 private function swallow ($ function , \Exception $ exception ) {
783- if (\ OC :: $ server -> getConfig ()-> getSystemValue ( ' smb.logging.enable ' , false ) === true ) {
791+ if ($ this -> logActive ) {
784792 Util::writeLog ('smb ' , "$ function swallowing " .\get_class ($ exception )
785793 .' - code: ' .$ exception ->getCode ()
786794 .' message: ' .$ exception ->getMessage ()
0 commit comments