Refactor logging level handling and remove example usage

* Updated `CommandLineOptions` and `ConfigurationObject` to use `LoggingLevel` type instead of string for log levels.
* Modified `LoggerFactory` to set logging levels using the new `LoggingLevelMapping` methods.
* Removed the `example-usage.ts` file as it was no longer needed.
* Adjusted `Threshold` class to simplify logging level management.
This commit is contained in:
2025-08-18 18:22:38 -04:00
parent 9e063550c2
commit 3875b3878d
7 changed files with 34 additions and 77 deletions

View File

@@ -7,4 +7,4 @@ type SupportedBrowser = {
real_mobile: boolean;
}
export default SupportedBrowser
export default SupportedBrowser;

View File

@@ -5,7 +5,7 @@ import {LoggingLevel, LoggingLevelMapping} from '../logger/LoggingLevel';
export interface CommandLineOptions {
applicationId: string;
secret: string;
logLevel: string;
logLevel: LoggingLevel;
pcastUri: string;
ingestUri: string;
channelUri: string;
@@ -27,7 +27,7 @@ interface ConfigurationObject {
useBrowserstackLocal: boolean;
browserstackUser: string;
browserstackKey: string;
logLevel: string;
logLevel: LoggingLevel;
applicationId: string;
secret: string;
pcastUri: string;
@@ -101,7 +101,7 @@ export default class CommandLine {
// Logging options
if (config.logLevel) {
args.push('--log-level', config.logLevel);
args.push('--log-level', LoggingLevelMapping.convertLoggingLevelToLoggingLevelType(config.logLevel));
}
return args;

View File

@@ -1,43 +0,0 @@
import CommandLine from './CommandLine';
// Example configuration object matching your structure
const config = {
viewers: ["chrome", "firefox"],
publishers: [],
tests: ["test/tests/real-time", "test/tests/dash", "test/tests/hls"],
useBrowserstack: false,
useBrowserstackLocal: false,
browserstackUser: "",
browserstackKey: "",
logLevel: "Info",
applicationId: "phenixrts.com-alex.zinn",
secret: "AMAsDzr.dIuGMZ.Zu52Dt~MQvP!DZwYg",
pcastUri: "https://pcast-stg.phenixrts.com",
ingestUri: "rtmp://ingest-stg.phenixrts.com:80/ingest",
channelUri: "https://pcast-stg.phenixrts.com/channel",
};
// Convert configuration to command line arguments
const args = CommandLine.configToArgs(config);
console.log('Generated command line arguments:');
console.log(args.join(' '));
console.log('\nThis generates the equivalent of:');
console.log('--application-id phenixrts.com-alex.zinn \\');
console.log('--secret AMAsDzr.dIuGMZ.Zu52Dt~MQvP!DZwYg \\');
console.log('--pcast-uri https://pcast-stg.phenixrts.com \\');
console.log('--channel-uri https://pcast-stg.phenixrts.com/channel \\');
console.log('--ingest-uri rtmp://ingest-stg.phenixrts.com:80/ingest \\');
console.log('--viewer chrome \\');
console.log('--viewer firefox \\');
console.log('--test test/tests/real-time \\');
console.log('--test test/tests/dash \\');
console.log('--test test/tests/hls \\');
console.log('--log-level Info');
console.log('\nNote: Users can pass --viewer, --publisher, and -t multiple times to build arrays');
// You can now use these arguments with the CommandLine.parse method
// const options = CommandLine.parse(args);
// console.log('Parsed options:', options);