Ver código fonte

moved the majority of old log entries to new logger

CauseFX 3 anos atrás
pai
commit
1e956d733c
40 arquivos alterados com 200 adições e 210 exclusões
  1. 2 2
      api/functions/2fa-functions.php
  2. 33 33
      api/functions/auth-functions.php
  3. 1 1
      api/functions/backup-functions.php
  4. 3 3
      api/functions/homepage-connect-functions.php
  5. 1 1
      api/functions/oauth.php
  6. 2 6
      api/functions/organizr-functions.php
  7. 18 18
      api/functions/sso-functions.php
  8. 14 15
      api/functions/update-functions.php
  9. 1 1
      api/homepage/couchpotato.php
  10. 4 4
      api/homepage/deluge.php
  11. 3 3
      api/homepage/emby.php
  12. 5 5
      api/homepage/healthchecks.php
  13. 1 1
      api/homepage/jackett.php
  14. 3 3
      api/homepage/jdownloader.php
  15. 3 3
      api/homepage/jellyfin.php
  16. 4 4
      api/homepage/lidarr.php
  17. 1 1
      api/homepage/monitorr.php
  18. 25 26
      api/homepage/netdata.php
  19. 2 2
      api/homepage/nzbget.php
  20. 1 1
      api/homepage/octoprint.php
  21. 5 5
      api/homepage/ombi.php
  22. 5 5
      api/homepage/overseerr.php
  23. 2 2
      api/homepage/pihole.php
  24. 1 1
      api/homepage/plex.php
  25. 4 4
      api/homepage/qbittorrent.php
  26. 2 2
      api/homepage/radarr.php
  27. 2 2
      api/homepage/rtorrent.php
  28. 2 2
      api/homepage/sickrage.php
  29. 3 3
      api/homepage/sonarr.php
  30. 1 1
      api/homepage/speedtest.php
  31. 1 1
      api/homepage/tautulli.php
  32. 2 2
      api/homepage/trakt.php
  33. 4 4
      api/homepage/transmission.php
  34. 5 5
      api/homepage/unifi.php
  35. 4 4
      api/homepage/utorrent.php
  36. 1 1
      api/homepage/weather.php
  37. 7 11
      api/plugins/bookmark/plugin.php
  38. 7 7
      api/plugins/healthChecks/plugin.php
  39. 12 12
      api/plugins/invites/plugin.php
  40. 3 3
      api/plugins/php-mailer/plugin.php

+ 2 - 2
api/functions/2fa-functions.php

@@ -83,7 +83,7 @@ trait TwoFAFunctions
 				)
 			),
 		];
-		$this->writeLog('success', 'User Management Function - User added 2FA', $this->user['username']);
+		$this->setLoggerChannel('Users')->info('User added 2FA');
 		$this->setAPIResponse('success', '2FA Added', 200);
 		return $this->processQueries($response);
 	}
@@ -101,7 +101,7 @@ trait TwoFAFunctions
 				)
 			),
 		];
-		$this->writeLog('success', 'User Management Function - User removed 2FA', $this->user['username']);
+		$this->setLoggerChannel('Users')->info('User removed 2FA');
 		$this->setAPIResponse('success', '2FA deleted', 204);
 		return $this->processQueries($response);
 	}

+ 33 - 33
api/functions/auth-functions.php

@@ -51,7 +51,7 @@ trait AuthFunctions
 				$provider = $ad->connect();
 			} catch (\Adldap\Auth\BindException $e) {
 				$detailedError = $e->getDetailedError();
-				$this->writeLog('error', 'LDAP Function - Error: ' . $detailedError->getErrorMessage(), 'SYSTEM');
+				$this->setLoggerChannel('LDAP')->error($e);
 				$this->setAPIResponse('error', $detailedError->getErrorMessage(), 409);
 				return $detailedError->getErrorMessage();
 				// There was an issue binding / connecting to the server.
@@ -69,7 +69,7 @@ trait AuthFunctions
 			return false;
 		}
 	}
-	
+
 	public function testConnectionLdapLogin($array)
 	{
 		$username = $array['username'] ?? null;
@@ -142,19 +142,19 @@ trait AuthFunctions
 				}
 			} catch (\Adldap\Auth\BindException $e) {
 				$detailedError = $e->getDetailedError();
-				$this->writeLog('error', 'LDAP Function - Error: ' . $detailedError->getErrorMessage(), $username);
+				$this->setLoggerChannel('LDAP')->error($e);
 				$this->setAPIResponse('error', $detailedError->getErrorMessage(), 500);
 				return $detailedError->getErrorMessage();
 				// There was an issue binding / connecting to the server.
 			} catch (Adldap\Auth\UsernameRequiredException $e) {
 				$detailedError = $e->getDetailedError();
-				$this->writeLog('error', 'LDAP Function - Error: ' . $detailedError->getErrorMessage(), $username);
+				$this->setLoggerChannel('LDAP')->error($e);
 				$this->setAPIResponse('error', $detailedError->getErrorMessage(), 422);
 				return $detailedError->getErrorMessage();
 				// The user didn't supply a username.
 			} catch (Adldap\Auth\PasswordRequiredException $e) {
 				$detailedError = $e->getDetailedError();
-				$this->writeLog('error', 'LDAP Function - Error: ' . $detailedError->getErrorMessage(), $username);
+				$this->setLoggerChannel('LDAP')->error($e);
 				$this->setAPIResponse('error', $detailedError->getErrorMessage(), 422);
 				return $detailedError->getErrorMessage();
 				// The user didn't supply a password.
@@ -164,7 +164,7 @@ trait AuthFunctions
 			return false;
 		}
 	}
-	
+
 	public function checkPlexToken($token = '')
 	{
 		try {
@@ -183,11 +183,11 @@ trait AuthFunctions
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('success', 'Plex Token Check Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Plex')->error($e);
 		}
 		return false;
 	}
-	
+
 	public function checkPlexUser($username)
 	{
 		try {
@@ -204,7 +204,7 @@ trait AuthFunctions
 						$usernameLower = strtolower($username);
 						foreach ($userXML as $child) {
 							if (isset($child['username']) && strtolower($child['username']) == $usernameLower || isset($child['email']) && strtolower($child['email']) == $usernameLower) {
-								$this->writeLog('success', 'Plex User Check - Found User on Friends List', $username);
+								$this->setLoggerChannel('Plex')->info('Found User on Friends List');
 								$machineMatches = false;
 								if ($this->config['plexStrictFriends']) {
 									foreach ($child->Server as $server) {
@@ -216,10 +216,10 @@ trait AuthFunctions
 									$machineMatches = true;
 								}
 								if ($machineMatches) {
-									$this->writeLog('success', 'Plex User Check - User Approved for Login', $username);
+									$this->setLoggerChannel('Plex')->info('User Approved for Login');
 									return true;
 								} else {
-									$this->writeLog('error', 'Plex User Check - User not Approved User', $username);
+									$this->setLoggerChannel('Plex')->warning('User not Approved User');
 								}
 							}
 						}
@@ -228,11 +228,11 @@ trait AuthFunctions
 			}
 			return false;
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Plex User Check Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('Plex')->error($e);
 		}
 		return false;
 	}
-	
+
 	public function plugin_auth_plex($username, $password)
 	{
 		try {
@@ -267,11 +267,11 @@ trait AuthFunctions
 			}
 			return false;
 		} catch (Requests_Exception $e) {
-			$this->writeLog('success', 'Plex Auth Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('Plex')->error($e);
 		}
 		return false;
 	}
-	
+
 	// Pass credentials to LDAP backend
 	public function plugin_auth_ldap($username, $password)
 	{
@@ -341,25 +341,25 @@ trait AuthFunctions
 					return false;
 				}
 			} catch (\Adldap\Auth\BindException $e) {
-				$this->writeLog('error', 'LDAP Function - Error: ' . $e->getMessage(), $username);
+				$this->setLoggerChannel('LDAP')->error($e);
 				// There was an issue binding / connecting to the server.
 			} catch (Adldap\Auth\UsernameRequiredException $e) {
-				$this->writeLog('error', 'LDAP Function - Error: ' . $e->getMessage(), $username);
+				$this->setLoggerChannel('LDAP')->error($e);
 				// The user didn't supply a username.
 			} catch (Adldap\Auth\PasswordRequiredException $e) {
-				$this->writeLog('error', 'LDAP Function - Error: ' . $e->getMessage(), $username);
+				$this->setLoggerChannel('LDAP')->error($e);
 				// The user didn't supply a password.
 			}
 		}
 		return false;
 	}
-	
+
 	// Ldap Auth Missing Dependency
 	public function plugin_auth_ldap_disabled()
 	{
 		return 'LDAP - Disabled (Dependency: php-ldap missing!)';
 	}
-	
+
 	// Pass credentials to FTP backend
 	public function plugin_auth_ftp($username, $password)
 	{
@@ -391,7 +391,7 @@ trait AuthFunctions
 			return false;
 		}
 	}
-	
+
 	// Pass credentials to Emby Backend
 	public function plugin_auth_emby_local($username, $password)
 	{
@@ -424,11 +424,11 @@ trait AuthFunctions
 			}
 			return false;
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Emby Local Auth Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('Emby')->error($e);
 		}
 		return false;
 	}
-	
+
 	// Pass credentials to JellyFin Backend
 	public function plugin_auth_jellyfin($username, $password)
 	{
@@ -446,7 +446,7 @@ trait AuthFunctions
 			if ($response->success) {
 				$json = json_decode($response->body, true);
 				if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
-					$this->writeLog('success', 'JellyFin Auth Function - Found User and Logged In', $username);
+					$this->setLoggerChannel('JellyFin')->info('Found User and Logged In');
 					// Login Success - Now Logout JellyFin Session As We No Longer Need It
 					$headers = array(
 						'X-Emby-Authorization' => 'MediaBrowser Client="Organizr Auth", Device="Organizr", DeviceId="orgv2", Version="2.0", Token="' . $json['AccessToken'] . '"',
@@ -460,11 +460,11 @@ trait AuthFunctions
 			}
 			return false;
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'JellyFin Auth Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('JellyFin')->error($e);
 		}
 		return false;
 	}
-	
+
 	// Authenticate against emby connect
 	public function plugin_auth_emby_connect($username, $password)
 	{
@@ -483,13 +483,13 @@ trait AuthFunctions
 						if (isset($value['ConnectUserName']) && isset($value['ConnectLinkType'])) { // Qualify as connect account
 							if (strtolower($value['ConnectUserName']) == strtolower($username) || strtolower($value['Name']) == strtolower($username)) {
 								$connectUserName = $value['ConnectUserName'];
-								$this->writeLog('success', 'Emby Connect Auth Function - Found User', $username);
+								$this->setLoggerChannel('Emby')->info('Found User');
 								break;
 							}
 						}
 					}
 					if ($connectUserName) {
-						$this->writeLog('success', 'Emby Connect Auth Function - Attempting to Login with Emby ID: ' . $connectUserName, $username);
+						$this->setLoggerChannel('Emby')->info('Attempting to Login with Emby ID: ' . $connectUserName);
 						$connectURL = 'https://connect.emby.media/service/user/authenticate';
 						$headers = array(
 							'Accept' => 'application/json',
@@ -508,21 +508,21 @@ trait AuthFunctions
 									//'image' => $json['User']['ImageUrl'],
 								);
 							} else {
-								$this->writeLog('error', 'Emby Connect Auth Function - Bad Response', $username);
+								$this->setLoggerChannel('Emby')->warning('Bad Response');
 							}
 						} else {
-							$this->writeLog('error', 'Emby Connect Auth Function - 401 From Emby Connect', $username);
+							$this->setLoggerChannel('Emby')->warning('401 From Emby Connect');
 						}
 					}
 				}
 			}
 			return false;
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Emby Connect Auth Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('Emby')->error($e);
 			return false;
 		}
 	}
-	
+
 	// Authenticate Against Emby Local (first) and Emby Connect
 	public function plugin_auth_emby_all($username, $password)
 	{
@@ -536,5 +536,5 @@ trait AuthFunctions
 			return $this->plugin_auth_emby_connect($username, $password);
 		}
 	}
-	
+
 }

+ 1 - 1
api/functions/backup-functions.php

@@ -22,7 +22,7 @@ trait BackupFunctions
 		$filename = $path . $filename;
 		if ($ext == 'zip') {
 			if (file_exists($filename)) {
-				$this->writeLog('success', 'Backup Manager Function -  Deleted Backup [' . pathinfo($filename, PATHINFO_BASENAME) . ']', $this->user['username']);
+				$this->setLoggerChannel('Backup')->info('Deleted Backup [' . pathinfo($filename, PATHINFO_BASENAME) . ']');
 				$this->setAPIResponse(null, pathinfo($filename, PATHINFO_BASENAME) . ' has been deleted', null);
 				return (unlink($filename));
 			} else {

+ 3 - 3
api/functions/homepage-connect-functions.php

@@ -76,14 +76,14 @@ trait HomepageConnectFunctions
 						break;
 				}
 				if ($response->success) {
-					$this->writeLog('success', 'OMBI Connect Function - Ran User Import', 'SYSTEM');
+					$this->setLoggerChannel('Ombi')->info('Ran User Import');
 					return true;
 				} else {
-					$this->writeLog('error', 'OMBI Connect Function - Error: Connection Unsuccessful', 'SYSTEM');
+					$this->setLoggerChannel('Ombi')->warning('Unsuccessful connection');
 					return false;
 				}
 			} catch (Requests_Exception $e) {
-				$this->writeLog('error', 'OMBI Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Ombi')->error($e);
 				return false;
 			}
 		}

+ 1 - 1
api/functions/oauth.php

@@ -93,7 +93,7 @@ trait OAuthFunctions
 					return true;
 				}
 			} catch (Requests_Exception $e) {
-				$this->writeLog('error', 'Trakt Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Trakt')->error($e);
 				$this->setResponse(500, $e->getMessage());
 				return false;
 			}

+ 2 - 6
api/functions/organizr-functions.php

@@ -150,14 +150,14 @@ trait OrganizrFunctions
 				$url = $this->config['embyURL'] . '/emby/Users/' . $userID . '/Connect/Link';
 				Requests::Post($url, $headers, json_encode($data), array());
 			} catch (Requests_Exception $e) {
-				$this->writeLog('error', 'Emby Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Emby')->error($e);
 				$this->setResponse(500, $e->getMessage());
 				return false;
 			}
 			$this->setAPIResponse('success', 'User has joined Emby', 200);
 			return true;
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Emby create Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Emby')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -175,8 +175,6 @@ trait OrganizrFunctions
 		$response = Requests::Get($url, $headers, array());
 		$response = $response->body;
 		$response = json_decode($response, true);
-		//error_Log("response ".json_encode($response));
-		$this->writeLog('error', 'userList:' . json_encode($response), 'SYSTEM');
 		//$correct stores the template users object
 		$correct = null;
 		foreach ($response as $element) {
@@ -184,14 +182,12 @@ trait OrganizrFunctions
 				$correct = $element;
 			}
 		}
-		$this->writeLog('error', 'Correct user:' . json_encode($correct), 'SYSTEM');
 		if ($correct == null) {
 			//return empty JSON if user incorrectly configured template
 			return "{}";
 		}
 		//select policy section and remove possibly dangerous rows.
 		$policy = $correct['Policy'];
-		//writeLog('error', 'policy update'.$policy, 'SYSTEM');
 		unset($policy['AuthenticationProviderId']);
 		unset($policy['InvalidLoginAttemptCount']);
 		unset($policy['DisablePremiumFeatures']);

+ 18 - 18
api/functions/sso-functions.php

@@ -170,16 +170,16 @@ trait SSOFunctions
 			$response = Requests::post($url . $endpoint, $headers, json_encode($data), $options);
 			if ($response->success) {
 				$token = json_decode($response->body, true);
-				$this->writeLog('success', 'Jellyfin Token Function - Grabbed token.', $username);
+				$this->setLoggerChannel('JellyFin')->info('Grabbed token');
 				$key = 'user-' . $token['User']['Id'] . '-' . $token['ServerId'];
 				$jellyfin[$key] = json_encode($token['User']);
 				$jellyfin['jellyfin_credentials'] = '{"Servers":[{"ManualAddress":"' . $ssoUrl . '","Id":"' . $token['ServerId'] . '","UserId":"' . $token['User']['Id'] . '","AccessToken":"' . $token['AccessToken'] . '"}]}';
 				return $jellyfin;
 			} else {
-				$this->writeLog('error', 'Jellyfin Token Function - Jellyfin did not return Token', $username);
+				$this->setLoggerChannel('JellyFin')->warning('JellyFin did not return Token');
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Jellyfin Token Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('Jellyfin')->error($e);
 		}
 		return false;
 	}
@@ -205,16 +205,16 @@ trait SSOFunctions
 			$response = Requests::post($url . $endpoint, $headers, json_encode($data), $options);
 			if ($response->success) {
 				$token = json_decode($response->body, true)['access_token'];
-				$this->writeLog('success', 'Ombi Token Function - Grabbed token.', $username);
+				$this->setLoggerChannel('Ombi')->info('Grabbed token');
 			} else {
 				if ($fallback) {
-					$this->writeLog('error', 'Ombi Token Function - Ombi did not return Token - Will retry using fallback credentials', $username);
+					$this->setLoggerChannel('Ombi')->warning('Ombi did not return Token - Will retry using fallback credentials');
 				} else {
-					$this->writeLog('error', 'Ombi Token Function - Ombi did not return Token', $username);
+					$this->setLoggerChannel('Ombi')->warning('Ombi did not return Token');
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Ombi Token Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('Ombi')->error($e);
 		}
 		if ($token) {
 			return $token;
@@ -253,12 +253,12 @@ trait SSOFunctions
 						$token[$key]['token'] = json_decode($response->body, true)['token'];
 						$token[$key]['uuid'] = json_decode($response->body, true)['uuid'];
 						$token[$key]['path'] = $path;
-						$this->writeLog('success', 'Tautulli Token Function - Grabbed token from: ' . $url, $username);
+						$this->setLoggerChannel('Tautulli')->info('Grabbed token from: ' . $url);
 					} else {
-						$this->writeLog('error', 'Tautulli Token Function - Error on URL: ' . $url, $username);
+						$this->setLoggerChannel('Tautulli')->warning('Error on URL: ' . $url);
 					}
 				} catch (Requests_Exception $e) {
-					$this->writeLog('error', 'Tautulli Token Function - Error: [' . $url . ']' . $e->getMessage(), $username);
+					$this->setLoggerChannel('Tautulli')->error($e);
 				}
 			}
 		}
@@ -285,16 +285,16 @@ trait SSOFunctions
 			if ($response->success) {
 				$user = json_decode($response->body, true); // not really needed yet
 				$token = $response->cookies['connect.sid']->value;
-				$this->writeLog('success', 'Overseerr Token Function - Grabbed token', $user['plexUsername'] ?? $email);
+				$this->setLoggerChannel('Overseerr')->info('Grabbed token');
 			} else {
 				if ($fallback) {
-					$this->writeLog('error', 'Overseerr Token Function - Overseerr did not return Token - Will retry using fallback credentials', $email);
+					$this->setLoggerChannel('Overseerr')->warning('Overseerr did not return Token - Will retry using fallback credentials');
 				} else {
-					$this->writeLog('error', 'Overseerr Token Function - Overseerr did not return Token', $email);
+					$this->setLoggerChannel('Overseerr')->warning('Overseerr did not return Token');
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Overseerr Token Function - Error: ' . $e->getMessage(), $email);
+			$this->setLoggerChannel('Overseerr')->error($e);
 		}
 		if ($token) {
 			return urldecode($token);
@@ -329,16 +329,16 @@ trait SSOFunctions
 			if ($response->success) {
 				$user = json_decode($response->body, true)['user'];
 				$token = json_decode($response->body, true)['token'];
-				$this->writeLog('success', 'Petio Token Function - Grabbed token', $user['username']);
+				$this->setLoggerChannel('Petio')->info('Grabbed token');
 			} else {
 				if ($fallback) {
-					$this->writeLog('error', 'Petio Token Function - Petio did not return Token - Will retry using fallback credentials', $username);
+					$this->setLoggerChannel('Petio')->warning('Petio did not return Token - Will retry using fallback credentials');
 				} else {
-					$this->writeLog('error', 'Petio Token Function - Petio did not return Token', $username);
+					$this->setLoggerChannel('Petio')->warning('Petio did not return Token');
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Petio Token Function - Error: ' . $e->getMessage(), $username);
+			$this->setLoggerChannel('Petio')->error($e);
 		}
 		if ($token) {
 			return $token;

+ 14 - 15
api/functions/update-functions.php

@@ -12,7 +12,7 @@ trait UpdateFunctions
 			return $this->linuxUpdate();
 		}
 	}
-	
+
 	public function dockerUpdate()
 	{
 		if (!$this->docker) {
@@ -37,7 +37,7 @@ trait UpdateFunctions
 			return false;
 		}
 	}
-	
+
 	public function windowsUpdate()
 	{
 		if ($this->docker || $this->getOS() !== 'win') {
@@ -58,7 +58,7 @@ trait UpdateFunctions
 			return false;
 		}
 	}
-	
+
 	public function linuxUpdate()
 	{
 		if ($this->docker || $this->getOS() == 'win') {
@@ -79,7 +79,7 @@ trait UpdateFunctions
 			return false;
 		}
 	}
-	
+
 	public function upgradeInstall($branch = 'v2-master', $stage = '1')
 	{
 		// may kill this function in place for php script to run elsewhere
@@ -102,29 +102,29 @@ trait UpdateFunctions
 			$destination = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR;
 			switch ($stage) {
 				case '1':
-					$this->writeLog('success', 'Update Function -  Started Upgrade Process', $this->user['username']);
+					$this->setLoggerChannel('Update')->info('Started Upgrade Process');
 					if ($this->downloadFile($url, $file)) {
-						$this->writeLog('success', 'Update Function -  Downloaded Update File for Branch: ' . $branch, $this->user['username']);
+						$this->setLoggerChannel('Update')->info('Downloaded Update File for Branch: ' . $branch);
 						$this->setAPIResponse('success', 'Downloaded file successfully', 200);
 						return true;
 					} else {
-						$this->writeLog('error', 'Update Function -  Downloaded Update File Failed  for Branch: ' . $branch, $this->user['username']);
+						$this->setLoggerChannel('Update')->warning('Downloaded Update File Failed for Branch: ' . $branch);
 						$this->setAPIResponse('error', 'Download failed', 500);
 						return false;
 					}
 				case '2':
 					if ($this->unzipFile($file)) {
-						$this->writeLog('success', 'Update Function -  Unzipped Update File for Branch: ' . $branch, $this->user['username']);
+						$this->setLoggerChannel('Update')->info('Unzipped Update File for Branch: ' . $branch);
 						$this->setAPIResponse('success', 'Unzipped file successfully', 200);
 						return true;
 					} else {
-						$this->writeLog('error', 'Update Function -  Unzip Failed for Branch: ' . $branch, $this->user['username']);
+						$this->setLoggerChannel('Update')->warning('Unzip Failed for Branch: ' . $branch);
 						$this->setAPIResponse('error', 'Unzip failed', 500);
 						return false;
 					}
 				case '3':
 					if ($this->rcopy($source, $destination)) {
-						$this->writeLog('success', 'Update Function -  Files overwritten using Updated Files from Branch: ' . $branch, $this->user['username']);
+						$this->setLoggerChannel('Update')->info('Files overwritten using Updated Files from Branch: ' . $branch);
 						$updateComplete = $this->config['dbLocation'] . 'completed.txt';
 						if (!file_exists($updateComplete)) {
 							touch($updateComplete);
@@ -132,18 +132,18 @@ trait UpdateFunctions
 						$this->setAPIResponse('success', 'Files replaced successfully', 200);
 						return true;
 					} else {
-						$this->writeLog('error', 'Update Function -  Overwrite Failed for Branch: ' . $branch, $this->user['username']);
+						$this->setLoggerChannel('Update')->warning('Overwrite Failed for Branch: ' . $branch);
 						$this->setAPIResponse('error', 'File replacement failed', 500);
 						return false;
 					}
 				case '4':
 					if ($this->rrmdir($cleanup)) {
-						$this->writeLog('success', 'Update Function -  Deleted Update Files from Branch: ' . $branch, $this->user['username']);
-						$this->writeLog('success', 'Update Function -  Update Completed', $this->user['username']);
+						$this->setLoggerChannel('Update')->info('Deleted Update Files from Branch: ' . $branch);
+						$this->setLoggerChannel('Update')->info('Update Completed');
 						$this->setAPIResponse('success', 'Removed update files successfully', 200);
 						return true;
 					} else {
-						$this->writeLog('error', 'Update Function -  Removal of Update Files Failed for Branch: ' . $branch, $this->user['username']);
+						$this->setLoggerChannel('Update')->warning('Removal of Update Files Failed for Branch: ' . $branch);
 						$this->setAPIResponse('error', 'File removal failed', 500);
 						return false;
 					}
@@ -155,6 +155,5 @@ trait UpdateFunctions
 			$this->setAPIResponse('error', 'File permissions not set correctly', 500);
 			return false;
 		}
-		
 	}
 }

+ 1 - 1
api/homepage/couchpotato.php

@@ -75,7 +75,7 @@ trait CouchPotatoHomepageItem
 				$downloader = new Kryptonit3\CouchPotato\CouchPotato($value['url'], $value['token'], null, null, $options);
 				$calendar = $this->formatCouchCalendar($downloader->getMediaList(array('status' => 'active,done')), $key);
 			} catch (Exception $e) {
-				$this->writeLog('error', 'Radarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Radarr')->error($e);
 			}
 			if (!empty($calendar)) {
 				$calendarItems = array_merge($calendarItems, $calendar);

+ 4 - 4
api/homepage/deluge.php

@@ -77,7 +77,7 @@ trait DelugeHomepageItem
 			$this->setAPIResponse('success', 'API Connection succeeded', 200);
 			return true;
 		} catch (Exception $e) {
-			$this->writeLog('error', 'NZBGet Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Deluge')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -144,12 +144,12 @@ trait DelugeHomepageItem
 			}
 			$api['content']['queueItems'] = (empty($api['content']['queueItems'])) ? [] : $api['content']['queueItems'];
 			$api['content']['historyItems'] = false;
-		} catch (Excecption $e) {
-			$this->writeLog('error', 'Deluge Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+		} catch (Exception $e) {
+			$this->setLoggerChannel('Deluge')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
-		$api['content'] = isset($api['content']) ? $api['content'] : false;
+		$api['content'] = $api['content'] ?? false;
 		$this->setAPIResponse('success', null, 200, $api);
 		return $api;
 	}

+ 3 - 3
api/homepage/emby.php

@@ -195,7 +195,7 @@ trait EmbyHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Emby Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Emby')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -253,7 +253,7 @@ trait EmbyHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Emby Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Emby')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -313,7 +313,7 @@ trait EmbyHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Emby Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Emby')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}

+ 5 - 5
api/homepage/healthchecks.php

@@ -38,7 +38,7 @@ trait HealthChecksHomepageItem
 		];
 		return array_merge($homepageInformation, $homepageSettings);
 	}
-	
+
 	public function healthChecksHomepagePermissions($key = null)
 	{
 		$permissions = [
@@ -57,7 +57,7 @@ trait HealthChecksHomepageItem
 		];
 		return $this->homepageCheckKeyPermissions($key, $permissions);
 	}
-	
+
 	public function homepageOrderhealthchecks()
 	{
 		if ($this->homepageItemPermissions($this->healthChecksHomepagePermissions('main'))) {
@@ -73,7 +73,7 @@ trait HealthChecksHomepageItem
 				';
 		}
 	}
-	
+
 	public function getHealthChecks($tags = null)
 	{
 		if (!$this->homepageItemPermissions($this->healthChecksHomepagePermissions('main'), true)) {
@@ -93,7 +93,7 @@ trait HealthChecksHomepageItem
 					$api['content']['checks'] = array_merge($api['content']['checks'], $healthResults['checks']);
 				}
 			} catch (Requests_Exception $e) {
-				$this->writeLog('error', 'HealthChecks Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('HealthChecks')->error($e);
 			};
 		}
 		usort($api['content']['checks'], function ($a, $b) {
@@ -107,7 +107,7 @@ trait HealthChecksHomepageItem
 		$this->setAPIResponse('success', null, 200, $api);
 		return $api;
 	}
-	
+
 	public function healthChecksTags($tags)
 	{
 		$return = '?tag=';

+ 1 - 1
api/homepage/jackett.php

@@ -162,7 +162,7 @@ trait JackettHomepageItem
 				unset($apiData);
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Jackett blackhole download failed ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Jackett')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		};

+ 3 - 3
api/homepage/jdownloader.php

@@ -79,10 +79,10 @@ trait JDownloaderHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'JDownloader Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('JDownloader')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
-		};
+		}
 	}
 
 	public function jDownloaderHomepagePermissions($key = null)
@@ -157,7 +157,7 @@ trait JDownloaderHomepageItem
 				$api['content']['$status'] = array($temp['downloader_state'], $temp['grabber_collecting'], $temp['update_ready']);
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'JDownloader Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('JDownloader')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		};

+ 3 - 3
api/homepage/jellyfin.php

@@ -194,7 +194,7 @@ trait JellyfinHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Jellyfin Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Jellyfin')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -251,7 +251,7 @@ trait JellyfinHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Jellyfin Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('JellyFin')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -311,7 +311,7 @@ trait JellyfinHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Jellyfin Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('JellyFin')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}

+ 4 - 4
api/homepage/lidarr.php

@@ -41,7 +41,7 @@ trait LidarrHomepageItem
 					$this->settingsOption('calendar-time-format', 'calendarTimeFormat'),
 					$this->settingsOption('calendar-locale', 'calendarLocale'),
 					$this->settingsOption('calendar-limit', 'calendarLimit'),
-					$this->settingsOption('refresh', 'calendarRefresh'),					
+					$this->settingsOption('refresh', 'calendarRefresh'),
 					$this->settingsOption('blank', '', ['type' => 'html', 'html' => '<hr />']),
 					$this->settingsOption('blank', '', ['type' => 'html', 'html' => '<hr />']),
 					$this->settingsOption('enable', 'lidarrIcon', ['label' => 'Show Lidarr Icon']),
@@ -93,7 +93,7 @@ trait LidarrHomepageItem
 				$failed = true;
 				$ip = $value['url'];
 				$errors .= $ip . ': ' . $e->getMessage();
-				$this->writeLog('error', 'Lidarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Lidarr')->error($e);
 			}
 		}
 		if ($failed) {
@@ -160,7 +160,7 @@ trait LidarrHomepageItem
 					$queueItems = array_merge($queueItems, $queue);
 				}
 			} catch (Exception $e) {
-				$this->writeLog('error', 'Lidarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Lidarr')->error($e);
 			}
 		}
 		$api['content']['queueItems'] = $queueItems;
@@ -194,7 +194,7 @@ trait LidarrHomepageItem
 					$calendar = '';
 				}
 			} catch (Exception $e) {
-				$this->writeLog('error', 'Lidarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Lidarr')->error($e);
 			}
 			if (!empty($calendar)) {
 				$calendarItems = array_merge($calendarItems, $calendar);

+ 1 - 1
api/homepage/monitorr.php

@@ -160,7 +160,7 @@ trait MonitorrHomepageItem
 				];
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Monitorr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Monitorr')->error($e);
 			$this->setAPIResponse('error', $e->getMessage(), 401);
 			return false;
 		};

+ 25 - 26
api/homepage/netdata.php

@@ -82,9 +82,8 @@ trait NetDataHomepageItem
 		$api = $api ?? false;
 		$this->setAPIResponse('success', null, 200, $api);
 		return $api;
-		
 	}
-	
+
 	public function netdataSettingsArray($infoOnly = false)
 	{
 		$homepageInformation = [
@@ -193,7 +192,7 @@ trait NetDataHomepageItem
 		);
 		return array_merge($homepageInformation, $homepageSettings);
 	}
-	
+
 	public function netdataHomepagePermissions($key = null)
 	{
 		$permissions = [
@@ -211,7 +210,7 @@ trait NetDataHomepageItem
 		];
 		return $this->homepageCheckKeyPermissions($key, $permissions);
 	}
-	
+
 	public function homepageOrderNetdata()
 	{
 		if ($this->homepageItemPermissions($this->netdataHomepagePermissions('main'))) {
@@ -227,7 +226,7 @@ trait NetDataHomepageItem
 				';
 		}
 	}
-	
+
 	public function disk($dimension, $url)
 	{
 		$data = [];
@@ -244,11 +243,11 @@ trait NetDataHomepageItem
 				$data['max'] = $json['max'];
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Netdata Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Netdata')->error($e);
 		};
 		return $data;
 	}
-	
+
 	public function diskSpace($dimension, $url)
 	{
 		$data = [];
@@ -265,11 +264,11 @@ trait NetDataHomepageItem
 				$data['max'] = 100;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Netdata Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
-		};
+			$this->setLoggerChannel('Netdata')->error($e);
+		}
 		return $data;
 	}
-	
+
 	public function net($dimension, $url)
 	{
 		$data = [];
@@ -286,11 +285,11 @@ trait NetDataHomepageItem
 				$data['max'] = $json['max'];
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Netdata Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
-		};
+			$this->setLoggerChannel('Netdata')->error($e);
+		}
 		return $data;
 	}
-	
+
 	public function cpu($url)
 	{
 		$data = [];
@@ -306,11 +305,11 @@ trait NetDataHomepageItem
 				$data['units'] = '%';
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Netdata Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
-		};
+			$this->setLoggerChannel('Netdata')->error($e);
+		}
 		return $data;
 	}
-	
+
 	public function ram($url)
 	{
 		$data = [];
@@ -326,11 +325,11 @@ trait NetDataHomepageItem
 				$data['units'] = '%';
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Netdata Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
-		};
+			$this->setLoggerChannel('Netdata')->error($e);
+		}
 		return $data;
 	}
-	
+
 	public function swap($url)
 	{
 		$data = [];
@@ -346,11 +345,11 @@ trait NetDataHomepageItem
 				$data['units'] = '%';
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Netdata Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
-		};
+			$this->setLoggerChannel('Netdata')->error($e);
+		}
 		return $data;
 	}
-	
+
 	public function getPercent($val, $max)
 	{
 		if ($max == 0) {
@@ -359,7 +358,7 @@ trait NetDataHomepageItem
 			return ($val / $max) * 100;
 		}
 	}
-	
+
 	public function customNetdata($url, $id)
 	{
 		try {
@@ -417,15 +416,15 @@ trait NetDataHomepageItem
 						}
 					}
 				} catch (Requests_Exception $e) {
-					$this->writeLog('error', 'Netdata Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
-				};
+					$this->setLoggerChannel('Netdata')->error($e);
+				}
 			} else {
 				$data['error'] = 'custom definition incomplete';
 			}
 			return $data;
 		}
 	}
-	
+
 	public function parseMutators($val, $mutators)
 	{
 		$mutators = explode(',', $mutators);

+ 2 - 2
api/homepage/nzbget.php

@@ -71,7 +71,7 @@ trait NZBGetHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'NZBGet Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('NZBGet')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -140,7 +140,7 @@ trait NZBGetHomepageItem
 			$this->setAPIResponse('success', null, 200, $api);
 			return $api;
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'NZBGet Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('NZBGet')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}

+ 1 - 1
api/homepage/octoprint.php

@@ -98,7 +98,7 @@ trait OctoPrintHomepageItem
 					return false;
 				}
 			} catch (Requests_Exception $e) {
-				$this->writeLog('error', 'Octoprint Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Octoprint')->error($e);
 				$this->setResponse(500, $e->getMessage());
 				return false;
 			};

+ 5 - 5
api/homepage/ombi.php

@@ -80,7 +80,7 @@ trait OmbiHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'OMBI Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Ombi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -222,7 +222,7 @@ trait OmbiHomepageItem
 				});
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'OMBI Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Ombi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		};
@@ -348,7 +348,7 @@ trait OmbiHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'OMBI Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Ombi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -426,10 +426,10 @@ trait OmbiHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'OMBI Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Ombi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
-		};
+		}
 	}
 
 	public function ombiTVDefault($type)

+ 5 - 5
api/homepage/overseerr.php

@@ -77,7 +77,7 @@ trait OverseerrHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Overseerr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Overseerr')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -237,7 +237,7 @@ trait OverseerrHomepageItem
 				});
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Overseerr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Overseerr')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -430,7 +430,7 @@ trait OverseerrHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Overseerr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Overseerr')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -521,7 +521,7 @@ trait OverseerrHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Overseerr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Overseerr')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -558,7 +558,7 @@ trait OverseerrHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Overseerr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Overseerr')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}

+ 2 - 2
api/homepage/pihole.php

@@ -68,7 +68,7 @@ trait PiHoleHomepageItem
 				$failed = true;
 				$ip = $this->qualifyURL($url, true)['host'];
 				$errors .= $ip . ': ' . $e->getMessage();
-				$this->writeLog('error', 'Pi-hole Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('PiHole')->error($e);
 			};
 		}
 		if ($failed) {
@@ -134,7 +134,7 @@ trait PiHoleHomepageItem
 				}
 			} catch (Requests_Exception $e) {
 				$this->setResponse(500, $e->getMessage());
-				$this->writeLog('error', 'Pi-hole Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('PiHole')->error($e);
 				return false;
 			};
 		}

+ 1 - 1
api/homepage/plex.php

@@ -730,7 +730,7 @@ trait PlexHomepageItem
 					return $libraryList;
 				}
 			} catch (Requests_Exception $e) {
-				$this->writeLog('error', 'Plex Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Plex')->error($e);
 				return false;
 			};
 		}

+ 4 - 4
api/homepage/qbittorrent.php

@@ -91,12 +91,12 @@ trait QBitTorrentHomepageItem
 					return true;
 				}
 			} else {
-				$this->writeLog('error', 'qBittorrent Connect Function - Error: Could not get session ID', 'SYSTEM');
+				$this->setLoggerChannel('qBittorrent')->warning('Could not get session ID');
 				$this->setAPIResponse('error', 'qBittorrent Connect Function - Error: Could not get session ID', 409);
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'qBittorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('qBittorrent')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -189,12 +189,12 @@ trait QBitTorrentHomepageItem
 					return $api;
 				}
 			} else {
-				$this->writeLog('error', 'qBittorrent Connect Function - Error: Could not get session ID', 'SYSTEM');
+				$this->setLoggerChannel('qBittorrent')->warning('Could not get session ID');
 				$this->setAPIResponse('error', 'qBittorrent Connect Function - Error: Could not get session ID', 409);
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'qBittorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('qBittorrent')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}

+ 2 - 2
api/homepage/radarr.php

@@ -103,7 +103,7 @@ trait RadarrHomepageItem
 				$failed = true;
 				$ip = $value['url'];
 				$errors .= $ip . ': ' . $e->getMessage();
-				$this->writeLog('error', 'Radarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Radarr')->error($e);
 			}
 		}
 		if ($failed) {
@@ -224,7 +224,7 @@ trait RadarrHomepageItem
 					$calendar = '';
 				}
 			} catch (Exception $e) {
-				$this->writeLog('error', 'Radarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Radarr')->error($e);
 			}
 			if (!empty($calendar)) {
 				$calendarItems = array_merge($calendarItems, $calendar);

+ 2 - 2
api/homepage/rtorrent.php

@@ -104,7 +104,7 @@ trait RTorrentHomepageItem
 			return false;
 		} catch
 		(Requests_Exception $e) {
-			$this->writeLog('error', 'rTorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('rTorrent')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -277,7 +277,7 @@ trait RTorrentHomepageItem
 			}
 		} catch
 		(Requests_Exception $e) {
-			$this->writeLog('error', 'rTorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('rTorrent')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		};

+ 2 - 2
api/homepage/sickrage.php

@@ -79,7 +79,7 @@ trait SickRageHomepageItem
 				$failed = true;
 				$ip = $value['url'];
 				$errors .= $ip . ': ' . $e->getMessage();
-				$this->writeLog('error', 'SickRage Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('SickRage')->error($e);
 			}
 		}
 		if ($failed) {
@@ -130,7 +130,7 @@ trait SickRageHomepageItem
 					$calendarItems = array_merge($calendarItems, $sickrageHistory);
 				}
 			} catch (Exception $e) {
-				$this->writeLog('error', 'SickRage Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('SickRage')->error($e);
 			}
 		}
 		$this->setAPIResponse('success', null, 200, $calendarItems);

+ 3 - 3
api/homepage/sonarr.php

@@ -105,7 +105,7 @@ trait SonarrHomepageItem
 				$failed = true;
 				$ip = $value['url'];
 				$errors .= $ip . ': ' . $e->getMessage();
-				$this->writeLog('error', 'Sonarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Sonarr')->error($e);
 			}
 		}
 		if ($failed) {
@@ -192,7 +192,7 @@ trait SonarrHomepageItem
 					$queueItems = array_merge($queueItems, $queue);
 				}
 			} catch (Exception $e) {
-				$this->writeLog('error', 'Sonarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Sonarr')->error($e);
 			}
 		}
 		$api['content']['queueItems'] = $queueItems;
@@ -226,7 +226,7 @@ trait SonarrHomepageItem
 					$sonarrCalendar = '';
 				}
 			} catch (Exception $e) {
-				$this->writeLog('error', 'Sonarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Sonarr')->error($e);
 			}
 			if (!empty($sonarrCalendar)) {
 				$calendarItems = array_merge($calendarItems, $sonarrCalendar);

+ 1 - 1
api/homepage/speedtest.php

@@ -110,7 +110,7 @@ trait SpeedTestHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Speedtest Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Speedtest')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		};

+ 1 - 1
api/homepage/tautulli.php

@@ -283,7 +283,7 @@ trait TautulliHomepageItem
 					return $libraryList;
 				}
 			} catch (Requests_Exception $e) {
-				$this->writeLog('error', 'Tautulli Homepage Error - Unable to get list of libraries: ' . $e->getMessage(), 'SYSTEM');
+				$this->setLoggerChannel('Tautulli')->error($e);
 				return false;
 			}
 		}

+ 2 - 2
api/homepage/trakt.php

@@ -107,7 +107,7 @@ trait TraktHomepageItem
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Trakt Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Trakt')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			$errors = true;
 		}
@@ -122,7 +122,7 @@ trait TraktHomepageItem
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Trakt Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Trakt')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			$errors = true;
 		}

+ 4 - 4
api/homepage/transmission.php

@@ -79,12 +79,12 @@ trait TransmissionHomepageItem
 					return false;
 				}
 			} else {
-				$this->writeLog('error', 'Transmission Connect Function - Error: Could not get session ID', 'SYSTEM');
+				$this->setLoggerChannel('Transmission')->warning('Could not get session ID');
 				$this->setAPIResponse('error', 'Transmission Connect Function - Error: Could not get session ID', 500);
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Transmission Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Transmission')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -179,12 +179,12 @@ trait TransmissionHomepageItem
 					$api['content']['historyItems'] = false;
 				}
 			} else {
-				$this->writeLog('error', 'Transmission Connect Function - Error: Could not get session ID', 'SYSTEM');
+				$this->setLoggerChannel('Transmission')->warning('Could not get session ID');
 				$this->setAPIResponse('error', 'Transmission Connect Function - Error: Could not get session ID', 500);
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Transmission Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Transmission')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		};

+ 5 - 5
api/homepage/unifi.php

@@ -116,7 +116,7 @@ trait UnifiHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Unifi Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Unifi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -136,7 +136,7 @@ trait UnifiHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Unifi Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Unifi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -169,7 +169,7 @@ trait UnifiHomepageItem
 				return false;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Unifi Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Unifi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -198,7 +198,7 @@ trait UnifiHomepageItem
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Unifi Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Unifi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -229,7 +229,7 @@ trait UnifiHomepageItem
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Unifi Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Unifi')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}

+ 4 - 4
api/homepage/utorrent.php

@@ -78,7 +78,7 @@ trait uTorrentHomepageItem
 
 			$response = $this->getuTorrentToken();
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'uTorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('uTorrent')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -134,7 +134,7 @@ trait uTorrentHomepageItem
 				$this->updateConfigItems($uTorrentConfig);
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'uTorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('uTorrent')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -163,7 +163,7 @@ trait uTorrentHomepageItem
 			$response = Requests::get($url, $headers, $options);
 			$httpResponse = $response->status_code;
 			if ($httpResponse == 400) {
-				$this->writeLog('warn', 'uTorrent Token or Cookie Expired. Generating new session..', 'SYSTEM');
+				$this->setLoggerChannel('uTorrent')->warning('Token or Cookie Expired. Generating new session...');
 				$this->getuTorrentToken();
 				$response = Requests::get($url, $headers, $options);
 				$httpResponse = $response->status_code;
@@ -223,7 +223,7 @@ trait uTorrentHomepageItem
 				return $api;
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'uTorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('uTorrent')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}

+ 1 - 1
api/homepage/weather.php

@@ -137,7 +137,7 @@ trait WeatherHomepageItem
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'Weather And Air Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('Weather & Air')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		};

+ 7 - 11
api/plugins/bookmark/plugin.php

@@ -20,11 +20,6 @@ $GLOBALS['plugins']['Bookmark'] = array( // Plugin Name
 // Logo image under Public Domain from https://openclipart.org/detail/182527/open-book
 class Bookmark extends Organizr
 {
-	public function writeLog($type = 'error', $message = null, $username = null)
-	{
-		parent::writeLog($type, "Plugin 'Bookmark': " . $message, $username);
-	}
-
 	public function _bookmarkGetOrganizrTabInfo()
 	{
 		$response = [
@@ -549,7 +544,8 @@ class Bookmark extends Organizr
 		];
 		$tabInfo = $this->_getBookmarkTabById($id);
 		if ($tabInfo) {
-			$this->writeLog('success', 'Tab Delete Function -  Deleted Tab [' . $tabInfo['name'] . ']', $this->user['username']);
+
+			$this->setLoggerChannel('Bookmark')->info('Deleted Bookmark [' . $tabInfo['name'] . ']');
 			$this->setAPIResponse('success', 'Tab deleted', 204);
 			return $this->processQueries($response);
 		} else {
@@ -622,7 +618,7 @@ class Bookmark extends Organizr
 			),
 		];
 		$this->setAPIResponse(null, 'Tab added');
-		$this->writeLog('success', 'Tab Editor Function -  Added Tab for [' . $array['name'] . ']', $this->user['username']);
+		$this->setLoggerChannel('Bookmark')->info('Added Bookmark [' . $array['name'] . ']');
 		return $this->processQueries($response);
 	}
 
@@ -682,7 +678,7 @@ class Bookmark extends Organizr
 			),
 		];
 		$this->setAPIResponse(null, 'Tab info updated');
-		$this->writeLog('success', 'Tab Editor Function -  Edited Tab Info for [' . $tabInfo['name'] . ']', $this->user['username']);
+		$this->setLoggerChannel('Bookmark')->info('Edited Bookmark [' . $tabInfo['name'] . ']');
 		return $this->processQueries($response);
 	}
 
@@ -910,7 +906,7 @@ class Bookmark extends Organizr
 			),
 		];
 		$this->setAPIResponse(null, 'Category added');
-		$this->writeLog('success', 'Category Editor Function -  Added Category for [' . $array['category'] . ']', $this->user['username']);
+		$this->setLoggerChannel('Bookmark')->info('Added Bookmark Category [' . $array['category'] . ']');
 		$result = $this->processQueries($response);
 		$this->_correctDefaultCategory();
 		return $result;
@@ -960,7 +956,7 @@ class Bookmark extends Organizr
 			),
 		];
 		$this->setAPIResponse(null, 'Category info updated');
-		$this->writeLog('success', 'Category Editor Function -  Edited Category Info for [' . $categoryInfo['category'] . ']', $this->user['username']);
+		$this->setLoggerChannel('Bookmark')->info('Edited Bookmark Category [' . $categoryInfo['category'] . ']');
 		$result = $this->processQueries($response);
 		$this->_correctDefaultCategory();
 		return $result;
@@ -1012,7 +1008,7 @@ class Bookmark extends Organizr
 		];
 		$categoryInfo = $this->_getBookmarkCategoryById($id);
 		if ($categoryInfo) {
-			$this->writeLog('success', 'Category Delete Function -  Deleted Category [' . $categoryInfo['category'] . ']', $this->user['username']);
+			$this->setLoggerChannel('Bookmark')->info('Deleted Bookmark Category [' . $categoryInfo['category'] . ']');
 			$this->setAPIResponse('success', 'Category deleted', 204);
 			$result = $this->processQueries($response);
 			$this->_correctDefaultCategory();

+ 7 - 7
api/plugins/healthChecks/plugin.php

@@ -130,7 +130,7 @@ class HealthChecks extends Organizr
 			)
 		);
 	}
-	
+
 	public function _healthCheckPluginTest($url)
 	{
 		$success = false;
@@ -156,12 +156,12 @@ class HealthChecks extends Organizr
 				}
 			}
 		} catch (Requests_Exception $e) {
-			$this->writeLog('error', 'HealthChecks Plugin - Error: ' . $e->getMessage(), 'SYSTEM');
+			$this->setLoggerChannel('HealthChecks')->error($e);
 			return false;
 		}
 		return $success;
 	}
-	
+
 	public function _healthCheckSelfHostedURLValidation($url, $checkOnly = false)
 	{
 		$selfHosted = true;
@@ -175,7 +175,7 @@ class HealthChecks extends Organizr
 		}
 		return $checkOnly ? $selfHosted : $url;
 	}
-	
+
 	public function _healthCheckPluginStartUUID($uuid)
 	{
 		if (!$uuid || $this->config['HEALTHCHECKS-PingURL'] == '') {
@@ -186,7 +186,7 @@ class HealthChecks extends Organizr
 		$options = ($this->localURL($url)) ? array('verify' => false) : array('verify' => $this->getCert());
 		return Requests::get($url . $uuid . '/start', [], $options);
 	}
-	
+
 	public function _healthCheckPluginUUID($uuid, $pass = false)
 	{
 		if (!$uuid || $this->config['HEALTHCHECKS-PingURL'] == '') {
@@ -198,7 +198,7 @@ class HealthChecks extends Organizr
 		$options = ($this->localURL($url)) ? array('verify' => false) : array('verify' => $this->getCert());
 		return Requests::get($url . $uuid . $path, [], $options);
 	}
-	
+
 	public function _healthCheckPluginRun()
 	{
 		$continue = $this->config['HEALTHCHECKS-all-items'] !== '' ? $this->config['HEALTHCHECKS-all-items'] : false;
@@ -208,7 +208,7 @@ class HealthChecks extends Organizr
 		if ($continue && $this->config['HEALTHCHECKS-enabled'] && !empty($this->config['HEALTHCHECKS-PingURL']) && $this->qualifyRequest($this->config['HEALTHCHECKS-Auth-include'])) {
 			$allItems = [];
 			foreach ($this->config['HEALTHCHECKS-all-items'] as $k => $v) {
-				
+
 				if ($k !== false) {
 					foreach ($v as $item) {
 						$allItems[$k][$item['label']] = $item['value'];

+ 12 - 12
api/plugins/invites/plugin.php

@@ -137,7 +137,7 @@ class Invites extends Organizr
 		];
 		$query = $this->processQueries($response);
 		if ($query) {
-			$this->writeLog('success', 'Invite Management Function -  Added Invite [' . $code . ']', $this->user['username']);
+			$this->setLoggerChannel('Invites')->info('Added Invite [' . $code . ']');
 			if ($this->config['PHPMAILER-enabled']) {
 				$PhpMailer = new PhpMailer();
 				$emailTemplate = array(
@@ -255,7 +255,7 @@ class Invites extends Organizr
 				)
 			];
 			$query = $this->processQueries($response);
-			$this->writeLog('success', 'Invite Management Function -  Invite Used [' . $code . ']', 'SYSTEM');
+			$this->setLoggerChannel('Invites')->info('Invite Used [' . $code . ']');
 			return $this->_invitesPluginAction($usedBy, 'share', $this->config['INVITES-type-include']);
 		} else {
 			return false;
@@ -295,7 +295,7 @@ class Invites extends Organizr
 							return $libraryList;
 						}
 					} catch (Requests_Exception $e) {
-						$this->writeLog('error', 'Plex Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+						$this->setLoggerChannel('Plex')->error($e);
 						return false;
 					};
 				}
@@ -526,36 +526,36 @@ class Invites extends Organizr
 								return false;
 						}
 						if ($response->success) {
-							$this->writeLog('success', 'Plex Invite Function - Plex User now has access to system', $username);
+							$this->setLoggerChannel('Invites')->info('Plex User now has access to system');
 							$this->setAPIResponse('success', 'Plex User now has access to system', 200);
 							return true;
 						} else {
 							switch ($response->status_code) {
 								case 400:
-									$this->writeLog('error', 'Plex Invite Function - Plex User already has access', $username);
+									$this->setLoggerChannel('Plex')->warning('Plex User already has access');
 									$this->setAPIResponse('error', 'Plex User already has access', 409);
 									return false;
 								case 401:
-									$this->writeLog('error', 'Plex Invite Function - Incorrect Token', 'SYSTEM');
+									$this->setLoggerChannel('Plex')->warning('Incorrect Token');
 									$this->setAPIResponse('error', 'Incorrect Token', 409);
 									return false;
 								case 404:
-									$this->writeLog('error', 'Plex Invite Function - Libraries not setup correct [' . $this->config['INVITES-plexLibraries'] . ']', 'SYSTEM');
+									$this->setLoggerChannel('Plex')->warning('Libraries not setup correctly');
 									$this->setAPIResponse('error', 'Libraries not setup correct', 409);
 									return false;
 								default:
-									$this->writeLog('error', 'Plex Invite Function - An error occurred [' . $response->status_code . ']', $username);
+									$this->setLoggerChannel('Plex')->warning('An error occurred [' . $response->status_code . ']');
 									$this->setAPIResponse('error', 'An Error Occurred', 409);
 									return false;
 							}
 						}
 					} catch (Requests_Exception $e) {
-						$this->writeLog('error', 'Plex Invite Function - Error: ' . $e->getMessage(), 'SYSTEM');
+						$this->setLoggerChannel('Plex')->error($e);
 						$this->setAPIResponse('error', $e->getMessage(), 409);
 						return false;
-					};
+					}
 				} else {
-					$this->writeLog('error', 'Plex Invite Function - Plex Token/ID not set', 'SYSTEM');
+					$this->setLoggerChannel('Plex')->warning('Plex Token/ID not set');
 					$this->setAPIResponse('error', 'Plex Token/ID not set', 409);
 					return false;
 				}
@@ -566,7 +566,7 @@ class Invites extends Organizr
 					$this->setAPIResponse('success', 'User now has access to system', 200);
 					return true;
 				} catch (Requests_Exception $e) {
-					$this->writeLog('error', 'Emby Invite Function - Error: ' . $e->getMessage(), 'SYSTEM');
+					$this->setLoggerChannel('Emby')->error($e);
 					$this->setAPIResponse('error', $e->getMessage(), 409);
 					return false;
 				}

+ 3 - 3
api/plugins/php-mailer/plugin.php

@@ -177,12 +177,12 @@ class PhpMailer extends Organizr
 			$mail->Subject = $emailTemplate['subject'];
 			$mail->Body = $this->_phpMailerPluginBuildEmail($emailTemplate);
 			$mail->send();
-			$this->writeLog('success', 'Mail Function -  E-Mail Test Sent', $this->user['username']);
+			$this->setLoggerChannel('Email')->info('E-Mail Test Sent');
 			$msg = ($this->config['PHPMAILER-debugTesting']) ? $this->config['phpmOriginalDebug'] : 'Email sent';
 			$this->setAPIResponse('success', $msg, 200);
 			return true;
 		} catch (PHPMailer\PHPMailer\Exception $e) {
-			$this->writeLog('error', 'Mail Function -  E-Mail Test Failed[' . $mail->ErrorInfo . ']', $this->user['username']);
+			$this->setLoggerChannel('Email')->error($e);
 			$this->setResponse(500, $e->getMessage());
 			return false;
 		}
@@ -242,7 +242,7 @@ class PhpMailer extends Organizr
 			$mail->send();
 			return true;
 		} catch (PHPMailer\PHPMailer\Exception $e) {
-			$this->writeLog('error', 'Mail Function -  E-Mail Test Failed[' . $mail->ErrorInfo . ']', $this->user['username']);
+			$this->setLoggerChannel('Email')->error($e);
 			return $e->errorMessage();
 		}
 	}