Log cleanup

This commit is contained in:
Bryan Ashby 2023-01-06 18:55:24 -07:00
parent 60238de017
commit a1e54dee6d
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
2 changed files with 24 additions and 17 deletions

View File

@ -45,7 +45,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
} }
_selfUrlRequestHandler(req, resp) { _selfUrlRequestHandler(req, resp) {
this.log.debug({ url: req.url }, 'Received request for "self" URL'); this.log.trace({ url: req.url }, 'Request for "self"');
const url = new URL(req.url, `https://${req.headers.host}`); const url = new URL(req.url, `https://${req.headers.host}`);
let accountName = url.pathname.substring(url.pathname.lastIndexOf('/') + 1); let accountName = url.pathname.substring(url.pathname.lastIndexOf('/') + 1);
@ -60,8 +60,8 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
userFromAccount(accountName, (err, user) => { userFromAccount(accountName, (err, user) => {
if (err) { if (err) {
this.log.info( this.log.info(
{ accountName: accountName }, { reason: error.message, accountName: accountName },
'Unable to find user from account retrieving self url.' `No user "${accountName}" for "self"`
); );
return this._notFound(resp); return this._notFound(resp);
} }
@ -86,7 +86,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
_selfAsActorHandler(user, req, resp) { _selfAsActorHandler(user, req, resp) {
this.log.trace( this.log.trace(
{ username: user.username }, { username: user.username },
`Serving ActivityPub Actor for ${user.username}` `Serving ActivityPub Actor for "${user.username}"`
); );
const userSelfUrl = selfUrl(this.webServer, user); const userSelfUrl = selfUrl(this.webServer, user);
@ -111,13 +111,13 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
url: webFingerProfileUrl(this.webServer, user), url: webFingerProfileUrl(this.webServer, user),
// :TODO: we can start to define BBS related stuff with the community perhaps // :TODO: we can start to define BBS related stuff with the community perhaps
attachment: [ // attachment: [
{ // {
name: 'SomeNetwork Address', // name: 'SomeNetwork Address',
type: 'PropertyValue', // type: 'PropertyValue',
value: 'Mateo@21:1/121', // value: 'Mateo@21:1/121',
}, // },
], // ],
}; };
const publicKeyPem = user.getProperty(UserProps.PublicKeyMain); const publicKeyPem = user.getProperty(UserProps.PublicKeyMain);
@ -125,12 +125,12 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
bodyJson['publicKey'] = { bodyJson['publicKey'] = {
id: userSelfUrl + '#main-key', id: userSelfUrl + '#main-key',
owner: userSelfUrl, owner: userSelfUrl,
publicKeyPem: user.getProperty(UserProps.PublicKeyMain), publicKeyPem,
}; };
} else { } else {
this.log.debug( this.log.warn(
{ username: user.username }, { username: user.username },
'User does not have a publickey.' `No public key (${UserProps.PublicKeyMain}) for user "${user.username}"`
); );
} }

View File

@ -11,7 +11,6 @@ const {
} = require('../../../activitypub_util'); } = require('../../../activitypub_util');
const _ = require('lodash'); const _ = require('lodash');
const Log = require('../../../logger').log;
exports.moduleInfo = { exports.moduleInfo = {
name: 'WebFinger', name: 'WebFinger',
@ -26,6 +25,8 @@ exports.moduleInfo = {
exports.getModule = class WebFingerWebHandler extends WebHandlerModule { exports.getModule = class WebFingerWebHandler extends WebHandlerModule {
constructor() { constructor() {
super(); super();
this.log = require('../../../logger').log.child({ webHandler: 'WebFinger' });
} }
init(cb) { init(cb) {
@ -98,7 +99,10 @@ exports.getModule = class WebFingerWebHandler extends WebHandlerModule {
userFromAccount(accountName, (err, user) => { userFromAccount(accountName, (err, user) => {
if (err) { if (err) {
Log.warn({ error: err.message }, `Profile request failed: ${req.url}`); this.log.warn(
{ url: req.url, error: err.message, type: 'Profile' },
`No profile for "${accountName}" could be retrieved`
);
return this._notFound(resp); return this._notFound(resp);
} }
@ -155,7 +159,10 @@ exports.getModule = class WebFingerWebHandler extends WebHandlerModule {
userFromAccount(accountName, (err, user) => { userFromAccount(accountName, (err, user) => {
if (err) { if (err) {
Log.warn({ error: err.message }, `WebFinger failed: ${req.url}`); this.log.warn(
{ url: req.url, error: err.message, type: 'WebFinger' },
`No account for "${accountName}" could be retrieved`
);
return this._notFound(resp); return this._notFound(resp);
} }