Better logging

This commit is contained in:
Zach Copley 2009-08-18 23:41:24 +00:00
parent c049931dc7
commit 8507017c24
3 changed files with 39 additions and 24 deletions

View File

@ -31,7 +31,6 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php';
class FBConnectauthAction extends Action
{
var $fbuid = null;
var $fb_fields = null;
@ -44,6 +43,11 @@ class FBConnectauthAction extends Action
$this->fb_fields = $this->getFacebookFields($this->fbuid,
array('first_name', 'last_name', 'name'));
} else {
list($proxy, $ip) = common_client_ip();
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
"Failed auth attempt, proxy = $proxy, ip = $ip.");
$this->clientError(_('You must be logged into Facebook to ' .
'use Facebook Connect.'));
}
@ -63,7 +67,8 @@ class FBConnectauthAction extends Action
if (!empty($flink)) {
// User already has a linked Facebook account and shouldn't be here
common_debug('There is already a local user (' . $flink->user_id .
common_debug('Facebook Connect Plugin - ' .
'There is already a local user (' . $flink->user_id .
') linked with this Facebook (' . $this->fbuid . ').');
// We don't want these cookies
@ -95,7 +100,8 @@ class FBConnectauthAction extends Action
} else if ($this->arg('connect')) {
$this->connectNewUser();
} else {
common_debug(print_r($this->args, true), __FILE__);
common_debug('Facebook Connect Plugin - ' .
print_r($this->args, true));
$this->showForm(_('Something weird happened.'),
$this->trimmed('newname'));
}
@ -205,7 +211,6 @@ class FBConnectauthAction extends Action
function createNewUser()
{
if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
return;
@ -268,7 +273,8 @@ class FBConnectauthAction extends Action
common_set_user($user);
common_real_login(true);
common_debug("Registered new user $user->id from Facebook user $this->fbuid");
common_debug('Facebook Connect Plugin - ' .
"Registered new user $user->id from Facebook user $this->fbuid");
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
303);
@ -286,8 +292,9 @@ class FBConnectauthAction extends Action
$user = User::staticGet('nickname', $nickname);
if ($user) {
common_debug("Legit user to connect to Facebook: $nickname");
if (!empty($user)) {
common_debug('Facebook Connect Plugin - ' .
"Legit user to connect to Facebook: $nickname");
}
$result = $this->flinkUser($user->id, $this->fbuid);
@ -297,7 +304,8 @@ class FBConnectauthAction extends Action
return;
}
common_debug("Connected Facebook user $this->fbuid to local user $user->id");
common_debug('Facebook Connnect Plugin - ' .
"Connected Facebook user $this->fbuid to local user $user->id");
common_set_user($user);
common_real_login(true);
@ -311,12 +319,13 @@ class FBConnectauthAction extends Action
$result = $this->flinkUser($user->id, $this->fbuid);
if (!$result) {
if (empty($result)) {
$this->serverError(_('Error connecting user to Facebook.'));
return;
}
common_debug("Connected Facebook user $this->fbuid to local user $user->id");
common_debug('Facebook Connect Plugin - ' .
"Connected Facebook user $this->fbuid to local user $user->id");
// Return to Facebook connection settings tab
common_redirect(common_local_url('FBConnectSettings'), 303);
@ -324,16 +333,18 @@ class FBConnectauthAction extends Action
function tryLogin()
{
common_debug("Trying Facebook Login...");
common_debug('Facebook Connect Plugin - ' .
"Trying login for Facebook user $this->fbuid.");
$flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_CONNECT_SERVICE);
if ($flink) {
if (!empty($flink)) {
$user = $flink->getUser();
if (!empty($user)) {
common_debug("Logged in Facebook user $flink->foreign_id as user $user->id ($user->nickname)");
common_debug('Facebook Connect Plugin - ' .
"Logged in Facebook user $flink->foreign_id as user $user->id ($user->nickname)");
common_set_user($user);
common_real_login(true);
@ -342,7 +353,8 @@ class FBConnectauthAction extends Action
} else {
common_debug("No flink found for fbuid: $this->fbuid");
common_debug('Facebook Connect Plugin - ' .
"No flink found for fbuid: $this->fbuid - new user");
$this->showForm(null, $this->bestNewNickname());
}
@ -438,7 +450,8 @@ class FBConnectauthAction extends Action
return reset($infos);
} catch (Exception $e) {
common_log(LOG_WARNING, "Facebook client failure when requesting " .
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
"Facebook client failure when requesting " .
join(",", $fields) . " on uid " . $fb_uid .
" : ". $e->getMessage());
return null;

View File

@ -214,7 +214,7 @@ class FBConnectPlugin extends Plugin
$fbuid = $facebook->get_loggedin_user();
} catch (Exception $e) {
common_log(LOG_WARNING,
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
'Problem getting Facebook user: ' .
$e->getMessage());
}
@ -342,7 +342,7 @@ class FBConnectPlugin extends Plugin
}
function onStartLogout($action)
{
{
$action->logout();
$fbuid = $this->loggedIn();
@ -351,7 +351,8 @@ class FBConnectPlugin extends Plugin
$facebook = getFacebook();
$facebook->expire_session();
} catch (Exception $e) {
common_log(LOG_WARNING, 'Could\'t logout of Facebook: ' .
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
'Could\'t logout of Facebook: ' .
$e->getMessage());
}
}
@ -376,7 +377,8 @@ class FBConnectPlugin extends Plugin
}
} catch (Exception $e) {
common_log(LOG_WARNING, "Facebook client failure requesting profile pic!");
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
"Facebook client failure requesting profile pic!");
}
return $url;

View File

@ -186,7 +186,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction
$facebook->clear_cookie_state();
} catch (Exception $e) {
common_log(LOG_WARNING,
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
'Couldn\'t clear Facebook cookies: ' .
$e->getMessage());
}