Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
feat(logging): updating argv, default log level
Browse files Browse the repository at this point in the history
  • Loading branch information
agorskiy12 committed Apr 17, 2024
1 parent 4f2c170 commit 4225510
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/server/config/env/argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ yargs
.option('log-level', {
describe: 'Lowest level of log entries to show',
type: 'string',
choices: ['error', 'warn', 'log', 'info', 'debug', 'trace'],
default: process.env.NODE_ENV === 'development' ? 'log' : 'info',
choices: ['error', 'warn', 'log', 'dev', 'info', 'debug', 'trace'],
default: 'log',
// process.env.NODE_ENV === 'development' ? 'log' : 'info',
});

if (argv.rootModuleName && rootModuleNameEnvVarValue) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const listen = async ({

console.info('%s listening on port %d', context, port);
if (process.env.NODE_ENV === 'development' && context === '🌎 One App server') {
console.dev('🚀 One App Server is running on http://localhost:%d 🚀', port);
logger.dev('🚀 One App Server is running on http://localhost:%d 🚀', port);
}

addServer(instance);
Expand Down
3 changes: 2 additions & 1 deletion src/server/utils/cdnCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import path from 'node:path';
import fs, { promises as fsPromises } from 'node:fs';
import logger from './logging/logger';

export const getUserHomeDirectory = () => process.env.HOME || process.env.USERPROFILE;
export const cacheFileName = '.one-app-module-cache';
Expand All @@ -27,7 +28,7 @@ export const showCacheInfo = async () => {
const stats = await fsPromises.stat(oneAppModuleCachePath);
const fileSizeInMB = stats.size / (1024 * 1024); // bytes to mb
const cachePath = path.join('~', oneAppDirectoryName, cacheFileName);
console.info('Local module cache size is %sMB. To clear the cache, delete %s', fileSizeInMB.toFixed(2), cachePath);
logger.dev('Local module cache size is %sMB. To clear the cache, delete %s', fileSizeInMB.toFixed(2), cachePath);
} catch (error) {
console.error('There was error checking file stat', error);
}
Expand Down
3 changes: 2 additions & 1 deletion src/server/utils/logging/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default {
level: argv.logLevel,
customLevels: {
log: 35,
dev: process.env.NODE_ENV === 'development' ? 36 : 0,
dev: 36,
// process.env.NODE_ENV === 'development' ? 36 : 0,
},
dedupe: true,
errorKey: 'error',
Expand Down

0 comments on commit 4225510

Please sign in to comment.