有没有办法在loopback中生成用户活动日志?
答案 0 :(得分:3)
您可以创建boot script并使用strong-remoting hook记录所有用户活动。
服务器/引导/活性-log.js 强>
# Get file name of code you want to filter
fname = input("Enter file name: ")
if len(fname) < 1 : fname = "sample_html.html"
# Create a file handle, like opening the file...
f_handle = open(fname)
# Define your new file that you will write to...
f_new= open("new_html.html","w+")
# Loop through each line in file
for line in f_handle:
# If line doesn't start with what you want to replace then write line to file and continue
if not line.startswith("<section class"):
f_new.write(line)
continue
# You want to replace this line so split it into list of strings
strings = line.split()
# Set new value for first string in list
strings[0] = '<section>'
# Delete the strings you don't want, this is what you are filtering out
del strings[1:5]
# Join the strings to a new line and write it to file
new_line = " ".join(strings)
f_new.write(new_line)
# Close yor new file
f_new.close()