Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persistent log #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

brownchow
Copy link

@brownchow brownchow commented Dec 7, 2020

Hi shimberger:

maybe we can persistent log for later debuging. so I use gopkg.in/natefinch/lumberjack.v2 to persistent logfile, default is logs/server.log

and the log format change a bit

logformat before:

time="2020-12-07T16:01:22+08:00" level=info msg="Initializing HLS with directory '.gohls-data'"
time="2020-12-07T16:01:22+08:00" level=info msg="Starting index scan for filepath.MemIndex(d:\\videos)"
Path to ffmpeg executable: D:\Chrome\ffmpeg-4.2.3-win64-static\bin\ffmpeg.exe
Path to ffprobe executable: D:\Chrome\ffmpeg-4.2.3-win64-static\bin\ffprobe.exe
HLS data directory: .gohls-data/
Visit http://127.0.0.1:8080/
time="2020-12-07T16:01:22+08:00" level=info msg="Finished index scan for filepath.MemIndex(d:\\videos). Found 7 entries"
time="2020-12-07T16:01:23+08:00" level=warning msg="Error moving cache file into place: rename .gohls\\cache\\segments\\e9fa4f01c7f76999b2d5e80a182bcc9c1d85ec41.040692011 .gohls\\cache\\segments\\e9fa4f01c7f76999b2d5e80a182bcc9c1d85ec41: The process cannot access the file because it is being used by another process."

logformat now:

{"level":"info","msg":"Initializing HLS with directory '.gohls-data'","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"Starting index scan for filepath.MemIndex(D:\\firefox)","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"Path to ffmpeg executable: D:\\Chrome\\ffmpeg-4.2.3-win64-static\\bin\\ffmpeg.exe\n","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"Path to ffprobe executable: D:\\Chrome\\ffmpeg-4.2.3-win64-static\\bin\\ffprobe.exe\n","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"HLS data directory: .gohls-data/\n","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"Visit http://127.0.0.1:8080/\n","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"Starting index scan for filepath.MemIndex(D:\\videos)","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"Finished index scan for filepath.MemIndex(D:\\videos). Found 7 entries","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"info","msg":"Finished index scan for filepath.MemIndex(D:\\firefox). Found 39 entries","time":"2020-12-07 16:20:01.012 +0800 CST"}
{"level":"warning","msg":"Error moving cache file into place: rename .gohls\\cache\\segments\\9a28f72d24326cf307a22796b4948d5825fedb6d.588033891 .gohls\\cache\\segments\\9a28f72d24326cf307a22796b4948d5825fedb6d: The process cannot access the file because it is being used by another process.","time":"2020-12-07 16:20:02.012 +0800 CST"}

in internal/logger/logger.go, we config the log setttings in init() method, and in internal/cmd/serve.go, we import _ "github.com/shimberger/gohls/internal/logger" make init() called, so in the whole project, when we use logrus print info, the setting of logrus will be applied

@shimberger
Copy link
Owner

@brownchow if this is still interesting for you could you maybe change it so that logging to a file only happens if a global option --log-dir is enabled? this way people using it in a container can just continue using stdout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants