Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gateway
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HBP Medical Informatics Platform
gateway
Commits
873d9fce
Commit
873d9fce
authored
2 years ago
by
Steve Reis
Browse files
Options
Downloads
Patches
Plain Diff
feat: Added configurable log levels
parent
9fd3e5df
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/src/common/utils/shared.utils.ts
+14
-1
14 additions, 1 deletion
api/src/common/utils/shared.utils.ts
api/src/main.ts
+7
-1
7 additions, 1 deletion
api/src/main.ts
with
21 additions
and
2 deletions
api/src/common/utils/shared.utils.ts
+
14
−
1
View file @
873d9fce
...
@@ -2,15 +2,28 @@
...
@@ -2,15 +2,28 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import
{
import
{
BadRequestException
,
HttpException
,
HttpException
,
InternalServerErrorException
,
InternalServerErrorException
,
LogLevel
,
NotFoundException
,
NotFoundException
,
RequestTimeoutException
,
RequestTimeoutException
,
UnauthorizedException
,
UnauthorizedException
,
}
from
'
@nestjs/common
'
;
}
from
'
@nestjs/common
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
export
const
LOG_LEVELS
=
[
[
'
warn
'
,
'
error
'
],
[
'
warn
'
,
'
error
'
,
'
log
'
],
[
'
warn
'
,
'
error
'
,
'
log
'
,
'
verbose
'
],
[
'
warn
'
,
'
error
'
,
'
log
'
,
'
verbose
'
,
'
debug
'
],
];
export
const
getLogLevels
=
(
level
:
number
):
LogLevel
[]
=>
{
let
internLevel
=
level
-
1
;
if
(
internLevel
>
LOG_LEVELS
.
length
||
internLevel
<
0
)
internLevel
=
0
;
return
LOG_LEVELS
[
internLevel
]
as
LogLevel
[];
};
export
const
errorAxiosHandler
=
(
e
:
any
)
=>
{
export
const
errorAxiosHandler
=
(
e
:
any
)
=>
{
if
(
!
axios
.
isAxiosError
(
e
))
throw
new
InternalServerErrorException
(
e
);
if
(
!
axios
.
isAxiosError
(
e
))
throw
new
InternalServerErrorException
(
e
);
...
...
This diff is collapsed.
Click to expand it.
api/src/main.ts
+
7
−
1
View file @
873d9fce
import
{
NestFactory
}
from
'
@nestjs/core
'
;
import
{
NestFactory
}
from
'
@nestjs/core
'
;
import
{
NestExpressApplication
}
from
'
@nestjs/platform-express
'
;
import
{
NestExpressApplication
}
from
'
@nestjs/platform-express
'
;
import
{
AppModule
}
from
'
./main/app.module
'
;
import
*
as
cookieParser
from
'
cookie-parser
'
;
import
*
as
cookieParser
from
'
cookie-parser
'
;
import
{
getLogLevels
}
from
'
./common/utils/shared.utils
'
;
import
{
AppModule
}
from
'
./main/app.module
'
;
const
CORS_URL
=
process
.
env
.
CORS_URL
??
process
.
env
.
ENGINE_BASE_URL
;
const
CORS_URL
=
process
.
env
.
CORS_URL
??
process
.
env
.
ENGINE_BASE_URL
;
const
DEFAULT_LEVEL
=
process
.
env
.
NODE_ENV
===
'
production
'
?
1
:
4
;
const
LOG_LEVEL
=
process
.
env
.
LOG_LEVEL
?
parseInt
(
process
.
env
.
LOG_LEVEL
)
:
DEFAULT_LEVEL
;
async
function
bootstrap
()
{
async
function
bootstrap
()
{
const
app
=
await
NestFactory
.
create
<
NestExpressApplication
>
(
AppModule
,
{
const
app
=
await
NestFactory
.
create
<
NestExpressApplication
>
(
AppModule
,
{
...
@@ -15,6 +20,7 @@ async function bootstrap() {
...
@@ -15,6 +20,7 @@ async function bootstrap() {
CORS_URL
,
CORS_URL
,
],
],
},
},
logger
:
getLogLevels
(
LOG_LEVEL
),
});
});
app
.
use
(
cookieParser
());
app
.
use
(
cookieParser
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment