Exemplo n.º 1
0
        private GroupNameFile GetGroupNameFile(string fileId)
        {
            if (string.IsNullOrWhiteSpace(fileId))
            {
                return(null);
            }

            //修正转义
            fileId = fileId.Replace("%2F", "/");
            if (!fileId.EndsWith(".log"))
            {
                fileId = fileId + ".log";
            }

            if (!fileId.EndsWith(".log"))
            {
                fileId += ".log";
            }

            // "1.log"
            // "remotes/1.log"
            if (fileId.StartsWith('/'))
            {
                fileId = fileId.TrimStart('/');
            }

            var fileHelper    = FileHelper.Instance;
            var logDirectory  = fileHelper.CombineBaseDirectory("_nlogs");
            var groupNameFile = GroupNameFile.Create(logDirectory, fileId);

            return(groupNameFile);
        }
Exemplo n.º 2
0
        public List <string> SearchLogFiles(SearchLogFilesArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            var fileHelper     = FileHelper.Instance;
            var logDirectory   = fileHelper.CombineBaseDirectory("_nlogs");
            var groupNameFiles = GroupNameFile.GetFiles(logDirectory, true, "*.log").ToGroupNameFiles(logDirectory);
            var files          = groupNameFiles.Search(GroupNameSearchArgs.Create("/", args.Name, true)).OrderByGroupName().Select(x => x.GetFullGroupNameWithExtension()).ToList();

            return(files);
        }