mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
feat: add more logs to url
This commit is contained in:
parent
0a3c0f4ac4
commit
70d9367fd8
2 changed files with 54 additions and 45 deletions
|
|
@ -5,7 +5,8 @@ import 'winston-daily-rotate-file';
|
|||
|
||||
export * from './wikiOutput';
|
||||
|
||||
const logger = (process.env.NODE_ENV === 'test'
|
||||
const logger = (
|
||||
process.env.NODE_ENV === 'test'
|
||||
? Object.assign(console, {
|
||||
emerg: console.error.bind(console),
|
||||
alert: console.error.bind(console),
|
||||
|
|
@ -35,6 +36,7 @@ const logger = (process.env.NODE_ENV === 'test'
|
|||
maxSize: '20mb',
|
||||
maxFiles: '14d',
|
||||
dirname: LOG_FOLDER,
|
||||
level: 'info',
|
||||
}),
|
||||
new RendererTransport(),
|
||||
],
|
||||
|
|
@ -48,5 +50,6 @@ const logger = (process.env.NODE_ENV === 'test'
|
|||
dirname: LOG_FOLDER,
|
||||
}),
|
||||
],
|
||||
})) as winston.Logger;
|
||||
})
|
||||
) as winston.Logger;
|
||||
export { logger };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { networkInterfaces } from 'os';
|
||||
import { defaultServerIP } from '@/constants/urls';
|
||||
import { logger } from './log';
|
||||
|
||||
const nets = networkInterfaces();
|
||||
/**
|
||||
|
|
@ -34,5 +35,10 @@ export function getAvailableIPAddress(): string | undefined {
|
|||
* @param originalUrl might be `"http://0.0.0.0:5212/"`
|
||||
*/
|
||||
export function getLocalHostUrlWithActualIP(originalUrl: string): string {
|
||||
return originalUrl.replace(defaultServerIP, getAvailableIPAddress() ?? defaultServerIP);
|
||||
const localHostUrlWithActualIP = originalUrl.replace(defaultServerIP, getAvailableIPAddress() ?? defaultServerIP);
|
||||
logger.debug(
|
||||
`Current available address: ${JSON.stringify(ipAddresses, undefined, ' ')}\nand getAvailableIPAddress() returns ${getAvailableIPAddress() ?? 'undefined'}
|
||||
originalUrl: ${originalUrl} , localHostUrlWithActualIP ${localHostUrlWithActualIP}`,
|
||||
);
|
||||
return localHostUrlWithActualIP;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue