Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore global logger logs in dev #6198

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/controller/cmcd-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { appendCmcdQuery } from '@svta/common-media-library/cmcd/appendCmcdQuery
import type { CmcdEncodeOptions } from '@svta/common-media-library/cmcd/CmcdEncodeOptions';
import { uuid } from '@svta/common-media-library/utils/uuid';
import { BufferHelper } from '../utils/buffer-helper';
import { logger } from '../utils/logger';
import type { ComponentAPI } from '../types/component-api';
import type { Fragment } from '../loader/fragment';
import type { BufferCreatedData, MediaAttachedData } from '../types/events';
Expand Down Expand Up @@ -201,7 +200,7 @@ export default class CMCDController implements ComponentAPI {
su: !this.initialized,
});
} catch (error) {
logger.warn('Could not generate manifest CMCD data.', error);
this.hls.logger.warn('Could not generate manifest CMCD data.', error);
}
};

Expand Down Expand Up @@ -237,7 +236,7 @@ export default class CMCDController implements ComponentAPI {

this.apply(context, data);
} catch (error) {
logger.warn('Could not generate segment CMCD data.', error);
this.hls.logger.warn('Could not generate segment CMCD data.', error);
}
};

Expand Down
9 changes: 4 additions & 5 deletions src/loader/playlist-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import { Events } from '../events';
import { ErrorDetails, ErrorTypes } from '../errors';
import { logger } from '../utils/logger';
import M3U8Parser from './m3u8-parser';
import type { LevelParsed, VariableMap } from '../types/level';
import type {
Expand Down Expand Up @@ -221,10 +220,10 @@ class PlaylistLoader implements NetworkComponentAPI {
loaderContext.level === context.level
) {
// same URL can't overlap
logger.trace('[playlist-loader]: playlist request ongoing');
this.hls.logger.trace('[playlist-loader]: playlist request ongoing');
return;
}
logger.log(
this.hls.logger.log(
`[playlist-loader]: aborting previous loader for type: ${context.type}`,
);
loader.abort();
Expand Down Expand Up @@ -408,7 +407,7 @@ class PlaylistLoader implements NetworkComponentAPI {
levels[0].audioCodec &&
!levels[0].attrs.AUDIO
) {
logger.log(
this.hls.logger.log(
'[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one',
);
audioTracks.unshift({
Expand Down Expand Up @@ -555,7 +554,7 @@ class PlaylistLoader implements NetworkComponentAPI {
message += ` id: ${context.id} group-id: "${context.groupId}"`;
}
const error = new Error(message);
logger.warn(`[playlist-loader]: ${message}`);
this.hls.logger.warn(`[playlist-loader]: ${message}`);
let details = ErrorDetails.UNKNOWN;
let fatal = false;

Expand Down
5 changes: 3 additions & 2 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getLoggerFn(
: consolePrintFn(key, id);
}

let exportedLogger: ILogger = createLogger();
const exportedLogger: ILogger = createLogger();

export function enableLogs(
debugConfig: boolean | ILogger,
Expand Down Expand Up @@ -107,7 +107,8 @@ export function enableLogs(
return createLogger();
}
}
exportedLogger = newLogger;
// global exported logger uses the log methods from last call to `enableLogs`
Object.assign(exportedLogger, newLogger);
return newLogger;
}

Expand Down
Loading