/// <summary> /// Initializes a new instance of DataCapture logger with given params. /// </summary> /// <param name="logName">Name of the DataCapture Log file.</param> /// <param name="bufferSize">This corresponds to the file size (in KB). Default is set to 8192.</param> /// <param name="userPath">Location of the log file. Default is set to Application persistent path.</param> public Logger(string logName, int bufferSize = 8192, int maxElapsedSeconds = kDefaultMaxElapsedSeconds, string userPath = "", LoggerSuffixOption suffixOption = LoggerSuffixOption.SEQ_NO, Func <string> customSuffix = null) { this.bufferSize = bufferSize; var name = string.IsNullOrEmpty(logName) ? kDefaultFileName : Path.GetFileNameWithoutExtension(logName); var ext = string.IsNullOrEmpty(Path.GetExtension(logName)) ? kDefaultExtension : Path.GetExtension(logName); SetOutputPath(DataCapturePaths.Logs, name, ext, userPath, customSuffix, suffixOption); _producer = new Unity.Simulation.ChunkedStream(bufferSize: this.bufferSize, maxElapsedSeconds: maxElapsedSeconds, functor: (AsyncRequest <object> request) => { Unity.Simulation.FileProducer.Write(GetPath(), request.data as Array); return(AsyncRequest.Result.Completed); }); }
public void SetOutputPath(string type, string name, string extension, string userPath = "", Func <string> suffixAppend = null, LoggerSuffixOption option = LoggerSuffixOption.SEQ_NO) { _type = type; _userPath = userPath; _name = name; _extension = extension; _suffixAction = suffixAppend; _loggerSuffixOption = option; var path = Manager.Instance.GetDirectoryFor(_type, _userPath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Log.V("Output path set to : " + path); }