Skip to content

Commit

Permalink
Merge pull request #56 from DXS-GROUP/InDev
Browse files Browse the repository at this point in the history
Logging setup
  • Loading branch information
Nighty3098 authored Oct 6, 2024
2 parents 04efcde + 07a4226 commit ef46e5c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Binary file modified app/__pycache__/config.cpython-312.pyc
Binary file not shown.
Binary file modified app/__pycache__/routes.cpython-312.pyc
Binary file not shown.
9 changes: 8 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@

app_version = "0.3.6"

logging.basicConfig(filename=log_file_path, encoding='utf-8', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO, format='%(asctime)s | %(levelname)s | %(name)s | %(threadName)s : %(message)s')

logging.basicConfig(
encoding="utf-8",
datefmt="%m/%d/%Y %I:%M:%S %p",
level=logging.INFO,
format="%(asctime)s | %(levelname)s | %(name)s | %(threadName)s : %(message)s",
handlers=[logging.FileHandler(log_file_path), logging.StreamHandler()],
)
9 changes: 5 additions & 4 deletions app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

import psutil
import pynvml
from flask import Flask, jsonify, redirect, render_template, request

from config import app, app_version, dictConfig
from flask import Flask, jsonify, redirect, render_template, request
from func import convert_seconds_to_hhmm
from get_info import (fetch_arch, fetch_cpu_info, get_ip_address,
get_open_ports_and_services, get_uptime, gpu_info,
Expand All @@ -19,11 +18,13 @@
prev_net_io = psutil.net_io_counters()
prev_time = time.time()

@app.route('/api/date', methods=['GET'])

@app.route("/api/date", methods=["GET"])
def get_server_date():
current_time = datetime.now().strftime("%H:%M")
current_date = datetime.now().strftime("%d %b %y")
return jsonify({'current_time': current_time, 'current_date': current_date})
return jsonify({"current_time": current_time, "current_date": current_date})


@app.route("/api/version")
def get_version():
Expand Down
2 changes: 1 addition & 1 deletion app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

if __name__ == "__main__":
setproctitle("SDash")
app.logger.warning("!!! New User logging in")
app.logger.critical("!!! New User logging in")
app.run(debug=True, host=get_ip_address())

0 comments on commit ef46e5c

Please sign in to comment.