diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-02-03 04:18:27 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-02-03 04:18:27 +0900 |
| commit | 238c6a428be14f484dac102289af183aec2a48fd (patch) | |
| tree | 742f80c68a0f371558c1deb714256a041c09adef /src/remote/activitypub | |
| parent | Clean up (diff) | |
| download | sharkey-238c6a428be14f484dac102289af183aec2a48fd.tar.gz sharkey-238c6a428be14f484dac102289af183aec2a48fd.tar.bz2 sharkey-238c6a428be14f484dac102289af183aec2a48fd.zip | |
[Server] Use logger for logging
Diffstat (limited to 'src/remote/activitypub')
| -rw-r--r-- | src/remote/activitypub/logger.ts | 3 | ||||
| -rw-r--r-- | src/remote/activitypub/request.ts | 8 | ||||
| -rw-r--r-- | src/remote/activitypub/resolver.ts | 6 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/remote/activitypub/logger.ts b/src/remote/activitypub/logger.ts new file mode 100644 index 0000000000..a611f940c1 --- /dev/null +++ b/src/remote/activitypub/logger.ts @@ -0,0 +1,3 @@ +import { remoteLogger } from "../logger"; + +export const apLogger = remoteLogger.createSubLogger('ap', 'magenta'); diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index 366d7e19a4..519c8026bc 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -1,7 +1,6 @@ import { request } from 'https'; import { sign } from 'http-signature'; import { URL } from 'url'; -import * as debug from 'debug'; import * as crypto from 'crypto'; import { lookup, IRunOptions } from 'lookup-dns-cache'; import * as promiseAny from 'promise-any'; @@ -9,11 +8,12 @@ import * as promiseAny from 'promise-any'; import config from '../../config'; import { ILocalUser } from '../../models/user'; import { publishApLogStream } from '../../stream'; +import { apLogger } from './logger'; -const log = debug('misskey:activitypub:deliver'); +export const logger = apLogger.createSubLogger('deliver'); export default (user: ILocalUser, url: string, object: any) => new Promise(async (resolve, reject) => { - log(`--> ${url}`); + logger.info(`--> ${url}`); const timeout = 10 * 1000; @@ -43,7 +43,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise(async 'Digest': `SHA-256=${hash}` } }, res => { - log(`${url} --> ${res.statusCode}`); + logger.info(`${url} --> ${res.statusCode}`); if (res.statusCode >= 400) { reject(res); diff --git a/src/remote/activitypub/resolver.ts b/src/remote/activitypub/resolver.ts index 8ec0d125a0..bff84f5781 100644 --- a/src/remote/activitypub/resolver.ts +++ b/src/remote/activitypub/resolver.ts @@ -1,9 +1,9 @@ import * as request from 'request-promise-native'; -import * as debug from 'debug'; import { IObject } from './type'; import config from '../../config'; +import { apLogger } from './logger'; -const log = debug('misskey:activitypub:resolver'); +export const logger = apLogger.createSubLogger('resolver'); export default class Resolver { private history: Set<string>; @@ -67,7 +67,7 @@ export default class Resolver { !object['@context'].includes('https://www.w3.org/ns/activitystreams') : object['@context'] !== 'https://www.w3.org/ns/activitystreams' )) { - log(`invalid response: ${value}`); + logger.error(`invalid response: ${value}`); throw new Error('invalid response'); } |