1.0.2 • Published 6 years ago
@ssense/logger v1.0.2
Logger
Standard logger utility that complies with SSENSE development standards.
Usage
import {
Logger,
AppLogger,
LogLevel,
AccessLogger,
RequestLogger
} from '@ssense/framework';
const logger: Logger = new AppLogger(
'microservice name',
LogLevel.Info),
optionalStreamObject,
true // to enable stack trace in details
);
// optionalStreamObject: { write: Function }
try {
// some code that throws an error
} catch (error) {
logger.error(`Some error message`, someRequestId, anArrayOfTags, error.stack);
}
const requestLogger: RequestLogger = logger.getRequestLogger(requestId);
request.logger(message, tags, details);
// ...
// ...
const accessLogger = new AccessLogger('some app id');
// log http requests when set in your middleware
accessLogger.logRequest(req, res, next);In the AppLogger you have access to basic log methods: log, silly, verbose, info, warn, and error. You can also manipulate the logger configuration with the following functions:
enable(enabled: boolean);
setAppId(appId: string);
getAppId();
generateRequestId();
setLevel(level: LogLevel);
getLevel();
setPretty(pretty: boolean);
setStream(stream: {write: Function});
// Returns a RequestLogger with basic log functions sily, verbose, warn, info and error
getRequestLogger(requestId: string)AccessLogger is simply used in your middlewares to record http requests. It is similar to AppLogger but only has the following configuration functions available to it:
enable(enabled: boolean);
setPretty(pretty: boolean);
setStream(stream: {write: Function});
setAppId(appId: string);
setUserIdCallback(callback: UserIdCallback);1.0.2
6 years ago
1.0.2-alpha.3
6 years ago
1.0.2-alpha.2
6 years ago
1.0.2-alpha.0
6 years ago
1.0.2-alpha.1
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.2.2
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.5
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago