web: clean up logging usage, parameterize with ENV vars.
This commit is contained in:
@ -15,13 +15,15 @@ export class ApiLogAppender implements LogAppender {
|
||||
public batchSize = 10;
|
||||
public minimumTimePassedInSec = 60;
|
||||
public maximumTimePassedInSec = 120;
|
||||
public threshold = LogLevel.ALL;
|
||||
|
||||
private http = Axios.create();
|
||||
private msgBuffer: ApiMessage[] = [];
|
||||
private lastSent = 0;
|
||||
|
||||
constructor(public readonly apiEndpoint: string, public authToken?: string, public threshold?: LogLevel) {
|
||||
constructor(public readonly apiEndpoint: string, public authToken?: string, threshold?: LogLevel) {
|
||||
setInterval(this.checkPost, 1000);
|
||||
if (threshold) { this.threshold = threshold; }
|
||||
}
|
||||
|
||||
public appendMessage(msg: LogMessage): void {
|
||||
|
@ -4,7 +4,11 @@ import Logger from './logger';
|
||||
import LogAppender from './log-appender';
|
||||
|
||||
export class ConsoleLogAppender implements LogAppender {
|
||||
constructor(public threshold?: LogLevel) {}
|
||||
public threshold = LogLevel.ALL;
|
||||
|
||||
constructor(threshold?: LogLevel) {
|
||||
if (threshold) { this.threshold = threshold; }
|
||||
}
|
||||
|
||||
public appendMessage(msg: LogMessage): void {
|
||||
if (this.threshold && msg.level < this.threshold) { return; }
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { LogLevel, LogMessage } from './log-message';
|
||||
import Logger from './logger';
|
||||
export default interface LogAppender {
|
||||
threshold: LogLevel;
|
||||
appendMessage(message: LogMessage): void;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
export enum LogLevel { ALL = 0, DEBUG, LOG, INFO, WARN, ERROR, FATAL }
|
||||
export enum LogLevel { ALL = 0, TRACE, DEBUG, LOG, INFO, WARN, ERROR, FATAL }
|
||||
|
||||
export interface LogMessage {
|
||||
scope: string;
|
||||
|
@ -3,9 +3,10 @@ import assign from 'lodash.assign';
|
||||
import { ApiToken, LoginSubmit, Measure, MeasureConfig, Measurement, MeasurementMeta, User } from '@/models';
|
||||
import { Logger, logService } from '@/services/logging';
|
||||
|
||||
const logger = logService.getLogger('services/pm-api-client');
|
||||
|
||||
export class PmApiClient {
|
||||
private http: AxiosInstance;
|
||||
private log: Logger;
|
||||
|
||||
constructor(apiBase: string) {
|
||||
this.http = Axios.create({
|
||||
@ -19,8 +20,7 @@ export class PmApiClient {
|
||||
*/
|
||||
});
|
||||
|
||||
this.log = logService.getLogger('services/pm-api-client');
|
||||
this.log.trace('Initialized PmApiClient');
|
||||
logger.trace('Initialized PmApiClient');
|
||||
}
|
||||
|
||||
public setAuthToken(authToken: string) {
|
||||
|
Reference in New Issue
Block a user