Skip to content

Commit

Permalink
Merge pull request #1407 from sakura-tel/20230502-delete-log
Browse files Browse the repository at this point in the history
delete: drop logs
  • Loading branch information
fs5m8 authored May 14, 2023
2 parents 34def25 + 6cc5bbb commit 4cb73bb
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 269 deletions.
15 changes: 15 additions & 0 deletions migration/1683005883304-delete-log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class deleteLog1683005883304 implements MigrationInterface {
name = 'deleteLog1683005883304'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "log"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "log" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "domain" character varying(64) array NOT NULL DEFAULT '{}'::varchar[], "level" "log_level_enum" NOT NULL, "worker" character varying(8) NOT NULL, "machine" character varying(128) NOT NULL, "message" character varying(2048) NOT NULL, "data" jsonb NOT NULL DEFAULT '{}', CONSTRAINT "PK_350604cbdf991d5930d9e618fbd" PRIMARY KEY ("id"))`);

}

}
7 changes: 1 addition & 6 deletions src/client/app/admin/views/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<li><router-link to="/dashboard" active-class="active"><fa icon="home" fixed-width/>{{ $t('dashboard') }}</router-link></li>
<li><router-link to="/instance" active-class="active" v-if="$store.getters.isAdmin"><fa icon="cog" fixed-width/>{{ $t('instance') }}</router-link></li>
<li><router-link to="/queue" active-class="active"><fa :icon="faTasks" fixed-width/>{{ $t('queue') }}</router-link></li>
<li><router-link to="/logs" active-class="active"><fa :icon="faStream" fixed-width/>{{ $t('logs') }}</router-link></li>
<li><router-link to="/db" active-class="active" v-if="$store.getters.isAdmin"><fa :icon="faDatabase" fixed-width/>{{ $t('db') }}</router-link></li>
<li><router-link to="/moderators" active-class="active" v-if="$store.getters.isAdmin"><fa :icon="faHeadset" fixed-width/>{{ $t('moderators') }}</router-link></li>
<li><router-link to="/users" active-class="active"><fa icon="users" fixed-width/>{{ $t('users') }}</router-link></li>
Expand All @@ -48,7 +47,6 @@
<div v-if="page == 'dashboard'"><x-dashboard/></div>
<div v-if="page == 'instance'"><x-instance/></div>
<div v-if="page == 'queue'"><x-queue/></div>
<div v-if="page == 'logs'"><x-logs/></div>
<div v-if="page == 'db'"><x-db/></div>
<div v-if="page == 'moderators'"><x-moderators/></div>
<div v-if="page == 'users'"><x-users/></div>
Expand Down Expand Up @@ -76,7 +74,6 @@ import { version } from '../../config';
import XDashboard from './dashboard.vue';
import XInstance from './instance.vue';
import XQueue from './queue.vue';
import XLogs from './logs.vue';
import XDb from './db.vue';
import XModerators from './moderators.vue';
import XEmoji from './emoji.vue';
Expand All @@ -87,7 +84,7 @@ import XAbuse from './abuse.vue';
import XFederation from './federation.vue';
import XRelays from "./relays.vue";
import { faHeadset, faArrowLeft, faGlobe, faProjectDiagram, faExclamationCircle, faTasks, faStream, faDatabase } from '@fortawesome/free-solid-svg-icons';
import { faHeadset, faArrowLeft, faGlobe, faProjectDiagram, faExclamationCircle, faTasks, faDatabase } from '@fortawesome/free-solid-svg-icons';
import { faGrin } from '@fortawesome/free-regular-svg-icons';
// Detect the user agent
Expand All @@ -100,7 +97,6 @@ export default Vue.extend({
XDashboard,
XInstance,
XQueue,
XLogs,
XDb,
XModerators,
XEmoji,
Expand All @@ -126,7 +122,6 @@ export default Vue.extend({
faProjectDiagram,
faExclamationCircle,
faTasks,
faStream,
faDatabase,
};
},
Expand Down
121 changes: 0 additions & 121 deletions src/client/app/admin/views/logs.vue

This file was deleted.

2 changes: 0 additions & 2 deletions src/db/postgre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { entities as charts } from '../services/chart/entities';
import { dbLogger } from './logger';
import * as highlight from 'cli-highlight';

import { Log } from '../models/entities/log';
import { User } from '../models/entities/user';
import { DriveFile } from '../models/entities/drive-file';
import { DriveFolder } from '../models/entities/drive-folder';
Expand Down Expand Up @@ -119,7 +118,6 @@ export const entities = [
NoteUnread,
Page,
PageLike,
Log,
DriveFile,
DriveFolder,
Poll,
Expand Down
46 changes: 0 additions & 46 deletions src/models/entities/log.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { UserRepository } from './repositories/user';
import { NoteRepository } from './repositories/note';
import { DriveFileRepository } from './repositories/drive-file';
import { DriveFolderRepository } from './repositories/drive-folder';
import { Log } from './entities/log';
import { AccessToken } from './entities/access-token';
import { UserNotePining } from './entities/user-note-pinings';
import { SigninRepository } from './repositories/signin';
Expand Down Expand Up @@ -88,7 +87,6 @@ export const Signins = getCustomRepository(SigninRepository);
export const MessagingMessages = getCustomRepository(MessagingMessageRepository);
export const ReversiGames = getCustomRepository(ReversiGameRepository);
export const ReversiMatchings = getCustomRepository(ReversiMatchingRepository);
export const Logs = getRepository(Log);
export const Pages = getCustomRepository(PageRepository);
export const PageLikes = getCustomRepository(PageLikeRepository);
export const ModerationLogs = getCustomRepository(ModerationLogRepository);
Expand Down
76 changes: 0 additions & 76 deletions src/server/api/endpoints/admin/logs.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/services/logger.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import * as cluster from 'cluster';
import * as os from 'os';
import * as chalk from 'chalk';
import * as dateformat from 'dateformat';
import { envOption } from '../env';
import { getRepository } from 'typeorm';
import { Log } from '../models/entities/log';
import { genId } from '../misc/gen-id';
import config from '../config';

const SyslogPro = require('syslog-pro');
Expand Down Expand Up @@ -94,18 +90,6 @@ export default class Logger {
null as never;

send.bind(this.syslogClient)(message).catch(() => {});
} else {
const Logs = getRepository(Log);
Logs.insert({
id: genId(),
createdAt: new Date(),
machine: os.hostname(),
worker: worker.toString(),
domain: [this.domain].concat(subDomains).map(d => d.name),
level: level,
message: message.substring(0, 1000), // 1024を超えるとログが挿入できずエラーになり無限ループする
data: data,
} as Log).catch(() => {});
}
}
}
Expand Down

0 comments on commit 4cb73bb

Please sign in to comment.