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

fix!: 로그 저장 경로를 backend/logs로 원복 #629

Merged
merged 5 commits into from
Aug 2, 2023
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
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }}
MYSQL_USER=${{ secrets.MYSQL_USER }}
MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}
BACKUP_USER=${{ secrets.BACKUP_USER}}
BACKUP_PASSWORD=${{ secrets.BACKUP_PASSWORD }}
ADMIN_SLACK_ID=${{ secrets.ADMIN_SLACK_ID }}
DB_SCHEMA=${{ secrets.DB_SCHEMA }}
MODE=${{ secrets.MODE }}
NODE_ENV=${{ secrets.NODE_ENV }}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import swaggerJsdoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import jipDataSource from '~/app-data-source';
import { connectMode } from '~/config';
import { logger, morganMiddleware } from '~/logger';
import { FtAuthentication, FtStrategy, JwtStrategy } from '~/v1/auth/auth.strategy';
import swaggerOptions from '~/v1/swagger/swagger';
import errorConverter from '~/v1/utils/error/errorConverter';
import errorHandler from '~/v1/utils/error/errorHandler';
import { logger, morganMiddleware } from '~/v1/utils/logger';

// eslint-disable-next-line import/no-extraneous-dependencies
import { contract } from '@jiphyeonjeon-42/contracts';
Expand Down
2 changes: 2 additions & 0 deletions backend/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { getOauth42ApiOption, getOauthUrlOption } from './oauthOption';
import { getRuntimeMode } from './runtimeOption';
import { getSlackbotOAuthToken } from './slackbotOAuthTokenOption';

export * as logFormatOption from './logOption';

// .env 파일을 읽어서 process.env에 추가
dotenv.config();

Expand Down
2 changes: 1 addition & 1 deletion backend/src/config/logOption.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogLevel, LogLevelOption } from './config.type';
import type { LogLevel, LogLevelOption } from './config.type';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS 3.8에서 추가된 문법이네요!

import { RuntimeMode } from './runtimeOption';

export const levels = {
Expand Down
10 changes: 4 additions & 6 deletions backend/src/v1/utils/logger.ts → backend/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import {
transports,
} from 'winston';
import WinstonDaily from 'winston-daily-rotate-file';
import { logLevelOption } from '~/config';
import {
colors,
levels,
} from '~/config/logOption';
import { logFormatOption, logLevelOption } from '~/config';

const { colors, levels } = logFormatOption;

const {
combine, timestamp, printf, colorize, errors,
} = format;

addColors(colors);

const logDir = '../../logs';
const logDir = '../logs';
const logTimestampFormat = 'YYYY-MM-DD HH:mm:ss:ms';
const datePattern = 'YYYY-MM-DD';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/mysql.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FieldPacket } from 'mysql2';
import mysql from 'mysql2/promise';
import { logger } from '~/v1/utils/logger';
import { connectOption } from '~/config';
import { logger } from '~/logger';

export const DBError = 'DB error';

Expand Down
6 changes: 3 additions & 3 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createHttpTerminator } from 'http-terminator';
import { logger } from '~/v1/utils/logger';
import scheduler from '~/v1/utils/scheduler';
import { gracefulTerminationTimeout } from '~/config';
import jipDataSource from '~/app-data-source';
import { gracefulTerminationTimeout } from '~/config';
import { logger } from '~/logger';
import scheduler from '~/v1/utils/scheduler';
import app from './app';

const port = '3000';
Expand Down
6 changes: 3 additions & 3 deletions backend/src/v1/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as bcrypt from 'bcrypt';
import { NextFunction, Request, Response } from 'express';
import * as status from 'http-status';
import { randomUUID } from 'node:crypto';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import { oauth42ApiOption, oauthUrlOption } from '~/config';
import { logger } from '~/logger';
import UsersService from '~/v1/users/users.service';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import * as models from '../DTO/users.model';
import { updateSlackIdByUserId } from '../slack/slack.service';
import * as authJwt from './auth.jwt';
Expand Down
6 changes: 3 additions & 3 deletions backend/src/v1/auth/auth.validate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Request, Response } from 'express';
import * as status from 'http-status';
import { verify } from 'jsonwebtoken';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import { jwtOption } from '~/config';
import { logger } from '~/logger';
import UsersService from '~/v1/users/users.service';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { User } from '../DTO/users.model';
import { role } from './auth.type';

Expand Down
6 changes: 3 additions & 3 deletions backend/src/v1/auth/auth.validateDefaultNullUser.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Request, Response } from 'express';
import * as status from 'http-status';
import { verify } from 'jsonwebtoken';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import { jwtOption } from '~/config';
import { logger } from '~/logger';
import UsersService from '~/v1/users/users.service';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { User } from '../DTO/users.model';
import { role } from './auth.type';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/v1/books/books.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
NextFunction, Request, RequestHandler, Response,
} from 'express';
import * as status from 'http-status';
import { logger } from '~/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import isNullish from '~/v1/utils/isNullish';
import { logger } from '~/v1/utils/logger';
import * as BooksService from './books.service';
import * as types from './books.type';
import LikesService from './likes.service';
Expand Down
4 changes: 2 additions & 2 deletions backend/src/v1/books/books.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable prefer-regex-literals */
/* eslint-disable prefer-destructuring */
import axios from 'axios';
import jipDataSource from '~/app-data-source';
import { nationalIsbnApiKey, naverBookApiOption } from '~/config';
import { logger } from '~/logger';
import { executeQuery } from '~/mysql';
import * as errorCode from '~/v1/utils/error/errorCode';
import { logger } from '~/v1/utils/logger';
import { StringRows } from '~/v1/utils/types';
import jipDataSource from '~/app-data-source';
import * as models from './books.model';
import BooksRepository from './books.repository';
import {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/v1/histories/histories.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
NextFunction, Request, Response,
} from 'express';
import * as status from 'http-status';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import { logger } from '~/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import * as historiesService from './histories.service';

// eslint-disable-next-line import/prefer-default-export
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v1/lendings/lendings.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
NextFunction, Request, RequestHandler, Response,
} from 'express';
import * as status from 'http-status';
import { logger } from '~/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import * as lendingsService from './lendings.service';

export const create: RequestHandler = async (
Expand Down
6 changes: 3 additions & 3 deletions backend/src/v1/reservations/reservations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
NextFunction, Request, RequestHandler, Response,
} from 'express';
import * as status from 'http-status';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import { logger } from '~/logger';
import * as userUtils from '~/v1/users/users.utils';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import * as reservationsService from './reservations.service';

export const create: RequestHandler = async (
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v1/slack/slack.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextFunction, Request, Response } from 'express';
import * as status from 'http-status';
import { logger } from '~/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import * as slack from './slack.service';

export const updateSlackList = async (
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v1/slack/slack.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WebClient } from '@slack/web-api';
import { ResultSetHeader } from 'mysql2';
import { logger } from '~/v1/utils/logger';
import { botOAuthToken as token } from '~/config';
import { logger } from '~/logger';
import { executeQuery } from '~/mysql';
import UsersService from '~/v1/users/users.service';
import * as models from '../DTO/users.model';
Expand Down
7 changes: 3 additions & 4 deletions backend/src/v1/users/users.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import bcrypt from 'bcrypt';
import { NextFunction, Request, Response } from 'express';
import PasswordValidator from 'password-validator';
import * as status from 'http-status';
import { z } from 'zod';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import PasswordValidator from 'password-validator';
import { logger } from '~/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { User } from '../DTO/users.model';
import UsersService from './users.service';
import { searchSchema } from './users.types';
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v1/users/users.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { QueryRunner } from 'typeorm';
import jipDataSource from '~/app-data-source';
import { connectMode } from '~/config';
import { logger } from '~/v1/utils/logger';
import { logger } from '~/logger';
import UsersService from './users.service';

const usersService = new UsersService();
Expand Down
4 changes: 1 addition & 3 deletions backend/src/v1/utils/error/errorConverter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { NextFunction, Request, Response } from 'express';
import * as Status from 'http-status';
import ErrorResponse from './errorResponse';
import { logger } from '../logger';
import * as errorCode from './errorCode';
import ErrorResponse from './errorResponse';

export default function errorConverter(
err: Error | ErrorResponse,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/v1/utils/error/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextFunction, Request, Response } from 'express';
import * as Status from 'http-status';
import ErrorResponse from './errorResponse';
import { logger } from '../logger';
import { logger } from '~/logger';
import * as errorCode from './errorCode';
import ErrorResponse from './errorResponse';

export default function errorHandler(
err: Error | ErrorResponse,
Expand Down
5 changes: 1 addition & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ services:

backend:
container_name: backend
#image : node:16
build:
context: .
volumes:
#- ./backend/src/:/src/
- ./backend/logs:/logs
#command: ${MODE}
- ./backend/logs:/app/backend/logs
ports:
- 3000:3000
env_file: .env
Expand Down