Split out logging a bit, fix accept header parsing
This commit is contained in:
parent
31f10d0c78
commit
a5a72d8270
Binary file not shown.
|
@ -30,7 +30,7 @@ module.exports = class Log {
|
|||
const serializers = Log.standardSerializers();
|
||||
|
||||
this.log = bunyan.createLogger({
|
||||
name: 'ENiGMA½ BBS',
|
||||
name: 'ENiGMA½',
|
||||
streams: logStreams,
|
||||
serializers: serializers,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// ENiGMA½
|
||||
const Log = require('../../logger.js').log;
|
||||
const SysLog = require('../../logger.js').log;
|
||||
const ServerModule = require('../../server_module.js').ServerModule;
|
||||
const Config = require('../../config.js').get;
|
||||
const { Errors } = require('../../enig_error.js');
|
||||
|
@ -75,7 +75,6 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
//this.log = Log.child({ server: 'Web' });
|
||||
this.log = WebLog.createWebLog();
|
||||
|
||||
const config = Config();
|
||||
|
@ -133,14 +132,14 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
try {
|
||||
const normalizedName = _.camelCase(module.moduleInfo.name);
|
||||
if (!WebHandlerModule.isEnabled(normalizedName)) {
|
||||
this.log.info(
|
||||
SysLog.info(
|
||||
{ moduleName: normalizedName },
|
||||
'Web handler module not enabled'
|
||||
);
|
||||
return nextModule(null);
|
||||
}
|
||||
|
||||
Log.info(
|
||||
SysLog.info(
|
||||
{ moduleName: normalizedName },
|
||||
'Initializing web handler module'
|
||||
);
|
||||
|
@ -149,7 +148,7 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
return nextModule(err);
|
||||
});
|
||||
} catch (e) {
|
||||
this.log.error(
|
||||
SysLog.error(
|
||||
{ error: e.message },
|
||||
'Exception caught loading web handler'
|
||||
);
|
||||
|
@ -171,7 +170,7 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
if (this[name]) {
|
||||
const port = parseInt(config.contentServers.web[service].port);
|
||||
if (isNaN(port)) {
|
||||
this.log.error(
|
||||
SysLog.error(
|
||||
{
|
||||
port: config.contentServers.web[service].port,
|
||||
server: ModuleInfo.name,
|
||||
|
@ -206,7 +205,7 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
route = new Route(route);
|
||||
|
||||
if (!route.isValid()) {
|
||||
this.log.error(
|
||||
SysLog.error(
|
||||
{ route: route },
|
||||
'Cannot add route: missing or invalid required members'
|
||||
);
|
||||
|
@ -215,7 +214,7 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
|
||||
const routeKey = route.getRouteKey();
|
||||
if (routeKey in this.routes) {
|
||||
this.log.warn(
|
||||
SysLog.warn(
|
||||
{ route: route, routeKey: routeKey },
|
||||
'Cannot add route: duplicate method/path combination exists'
|
||||
);
|
||||
|
|
|
@ -6,6 +6,7 @@ const {
|
|||
getActorId,
|
||||
prepareLocalUserAsActor,
|
||||
} = require('../../../activitypub/util');
|
||||
const SysLog = require('../../../logger').log;
|
||||
const {
|
||||
ActivityStreamMediaType,
|
||||
WellKnownActivity,
|
||||
|
@ -182,7 +183,8 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
}
|
||||
|
||||
// Additionally, serve activity JSON if the proper 'Accept' header was sent
|
||||
const accept = req.headers['accept'].split(',').map(v => v.trim()) || ['*/*'];
|
||||
const accept = (req.headers.accept &&
|
||||
req.headers.accept.split(',').map(v => v.trim())) || ['*/*'];
|
||||
const headerValues = [
|
||||
ActivityStreamMediaType,
|
||||
'application/ld+json',
|
||||
|
@ -396,7 +398,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
_inboxAcceptFollowActivity(resp, activity) {
|
||||
// Currently Accept's to Follow's are really just a formality;
|
||||
// we'll log it, but that's about it for now
|
||||
this.log.info(
|
||||
SysLog.info(
|
||||
{
|
||||
remoteActorId: activity.actor,
|
||||
localActorId: _.get(activity, 'object.actor'),
|
||||
|
@ -626,7 +628,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
// :TODO: log me
|
||||
}
|
||||
|
||||
this.log.info({ stats, inboxType }, 'Inbox Delete request complete');
|
||||
SysLog.info({ stats, inboxType }, 'Inbox Delete request complete');
|
||||
return this.webServer.accepted(resp);
|
||||
}
|
||||
);
|
||||
|
@ -802,7 +804,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
return this.webServer.internalServerError(resp, err);
|
||||
}
|
||||
|
||||
this.log.info(
|
||||
SysLog.info(
|
||||
{
|
||||
username: localUser.username,
|
||||
userId: localUser.userId,
|
||||
|
@ -906,7 +908,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
return this.webServer.internalServerError(resp, err);
|
||||
}
|
||||
|
||||
this.log.info(
|
||||
SysLog.info(
|
||||
{
|
||||
inboxType,
|
||||
objectId: targetObjectId,
|
||||
|
@ -926,7 +928,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
}
|
||||
|
||||
_deliverNoteToSharedInbox(activity, note, cb) {
|
||||
this.log.info(
|
||||
SysLog.info(
|
||||
{ activityId: activity.id, noteId: note.id },
|
||||
'Delivering Note to Public/Shared inbox'
|
||||
);
|
||||
|
@ -957,9 +959,14 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
return cb(null); // not found/etc., just bail
|
||||
}
|
||||
|
||||
this.log.info(
|
||||
{ activityId: activity.id, noteId: note.id, actorId },
|
||||
'Delivering Note to local Actor Private inbox'
|
||||
this.sysLog.info(
|
||||
{
|
||||
activityId: activity.id,
|
||||
noteId: note.id,
|
||||
actorId,
|
||||
username: localUser.username,
|
||||
},
|
||||
`Delivering private Note to local Actor "${localUser.username}"`
|
||||
);
|
||||
|
||||
Collection.addInboxItem(activity, localUser, false, err => {
|
||||
|
@ -1209,7 +1216,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
}
|
||||
|
||||
_prepareNewUserAsActor(user, cb) {
|
||||
this.log.info(
|
||||
this.sysLog.info(
|
||||
{ username: user.username, userId: user.userId },
|
||||
`Preparing ActivityPub settings for "${user.username}"`
|
||||
);
|
||||
|
|
|
@ -27,8 +27,6 @@ exports.getModule = class SystemGeneralWebHandler extends WebHandlerModule {
|
|||
this.webServer = webServer;
|
||||
EngiAssert(webServer, 'System General Web Handler init without webServer');
|
||||
|
||||
this.log = webServer.logger().child({ webHandler: 'SysGeneral' });
|
||||
|
||||
const domain = getWebDomain();
|
||||
if (!domain) {
|
||||
return cb(Errors.UnexpectedState('Web server does not have "domain" set'));
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = class WebLog {
|
|||
serializers.res = bunyan.stdSerializers.res;
|
||||
|
||||
const webLog = bunyan.createLogger({
|
||||
name: 'ENiGMA½ BBS[Web]',
|
||||
name: 'ENiGMA½',
|
||||
streams: [rotatingFile],
|
||||
serializers,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue