Commit 2386ec06 authored by chenhan wang's avatar chenhan wang
Browse files

fix: drop the log file and only output the log to std flow

parent 3cf09dda
...@@ -6,4 +6,5 @@ conf.yaml ...@@ -6,4 +6,5 @@ conf.yaml
docs/** docs/**
**.exe **.exe
files/** files/**
**.log **.log
\ No newline at end of file **.sql
\ No newline at end of file
package middleware package middleware
import ( import (
"github.com/labstack/echo/v4" "fmt"
//"time"
"io"
"os"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
//"http/net"
//"pastebin_backend/app/controller"
) )
func Auth(next echo.HandlerFunc) echo.HandlerFunc { func Auth(next echo.HandlerFunc) echo.HandlerFunc {
...@@ -33,18 +29,10 @@ User-Agent,访问路径,暂且无法实现 ...@@ -33,18 +29,10 @@ User-Agent,访问路径,暂且无法实现
*/ */
func mylogger(c echo.Context) { func mylogger(c echo.Context) {
//c.GET("User-Agent") //c.GET("User-Agent")
//userAgent := controller.Ctx.Request.Header.Get("User-Agent") userAgent := c.Get("User-Agent")
ip := echo.ExtractIPDirect()(c.Request()) ip := echo.ExtractIPDirect()(c.Request())
msg := "User-Agent:" + fmt.Sprint(userAgent) + ",ip:" + ip + ",path:" + c.Path()
//日志输出文件 logrus.Println(msg)
file, err := os.OpenFile("files/sys.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
logrus.Fatalln("Faild to open error logger file:", err)
}
//同时写文件和屏幕
fileAndStdoutWriter := io.MultiWriter(os.Stdout, file)
logrus.SetOutput(fileAndStdoutWriter)
logrus.WithField("ip", ip).Info("info log")
} }
// 检测 uid 是否有效 // 检测 uid 是否有效
......
create database pastebin;
create user 'rootp'@'localhost' identified by 'pastebingroup1';
grant all privileges on pastebin.* to 'rootp'@'localhost';
use pastebin;
-- MySQL dump 10.13 Distrib 8.0.31, for Win64 (x86_64)
--
-- Host: localhost Database: pastebin
-- ------------------------------------------------------
-- Server version 8.0.31
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `contents`
--
DROP TABLE IF EXISTS `contents`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contents` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`s` longtext,
`time` bigint unsigned DEFAULT NULL,
`passwd` longtext,
`date` datetime(3) DEFAULT NULL,
`size` bigint unsigned DEFAULT NULL,
`time1` datetime(3) DEFAULT NULL,
`time2` bigint unsigned DEFAULT NULL,
`url1` longtext,
`filetype` longtext,
`filename` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `contents`
--
LOCK TABLES `contents` WRITE;
/*!40000 ALTER TABLE `contents` DISABLE KEYS */;
/*!40000 ALTER TABLE `contents` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `sid_urls`
--
DROP TABLE IF EXISTS `sid_urls`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sid_urls` (
`sid_id` bigint unsigned NOT NULL,
`url_id` bigint unsigned NOT NULL,
PRIMARY KEY (`sid_id`,`url_id`),
KEY `fk_sid_urls_url` (`url_id`),
CONSTRAINT `fk_sid_urls_sid` FOREIGN KEY (`sid_id`) REFERENCES `sids` (`id`),
CONSTRAINT `fk_sid_urls_url` FOREIGN KEY (`url_id`) REFERENCES `urls` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `sid_urls`
--
LOCK TABLES `sid_urls` WRITE;
/*!40000 ALTER TABLE `sid_urls` DISABLE KEYS */;
/*!40000 ALTER TABLE `sid_urls` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `sids`
--
DROP TABLE IF EXISTS `sids`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sids` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`time` datetime(3) DEFAULT NULL,
`s` longtext,
PRIMARY KEY (`id`),
KEY `idx_sids_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `sids`
--
LOCK TABLES `sids` WRITE;
/*!40000 ALTER TABLE `sids` DISABLE KEYS */;
/*!40000 ALTER TABLE `sids` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `urls`
--
DROP TABLE IF EXISTS `urls`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `urls` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`url1` longtext,
PRIMARY KEY (`id`),
KEY `idx_urls_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `urls`
--
LOCK TABLES `urls` WRITE;
/*!40000 ALTER TABLE `urls` DISABLE KEYS */;
/*!40000 ALTER TABLE `urls` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`session_id` longtext,
`username` longtext,
`passwd` longtext,
`name` longtext,
`size` bigint unsigned DEFAULT NULL,
`route` longtext
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-01-17 22:07:33
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment