hf-smug-demo / app.py
rajivmehtapy's picture
add logger package.
b5d9a88
raw
history blame
483 Bytes
import gradio as gr
import os
from loguru import logger
# Create a directory for logs if it doesn't exist
if not os.path.exists('logs'):
os.makedirs('logs')
# Define the log file path
log_file = 'logs/file_{time}.log'
# Configure the logger to write to the log file
logger.add(log_file, rotation="500 MB")
def greet(name):
logger.info("This is an info message")
return "Hi , " + name + "!!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()