public HostFileLoggerProvider(IOptions <ScriptJobHostOptions> options, IFileLoggingStatusManager fileLoggingStatusManager, IFileWriterFactory fileWriterFactory)
        {
            if (fileWriterFactory == null)
            {
                throw new ArgumentNullException(nameof(fileWriterFactory));
            }

            _writer = fileWriterFactory.Create(Path.Combine(options.Value.RootLogPath, "Host"));
            _isFileLoggingEnabled = () => fileLoggingStatusManager.IsFileLoggingEnabled;
        }
        public ILogger CreateLogger(string categoryName)
        {
            string filePath = GetFilePath(categoryName);

            if (filePath != null)
            {
                // Make sure that we return the same fileWriter if multiple loggers write to the same path. This happens
                // with Function logs as Function.{FunctionName} and Function.{FunctionName}.User both go to the same file.
                IFileWriter fileWriter = _fileWriterCache.GetOrAdd(filePath, (p) => _fileWriterFactory.Create(Path.Combine(_roogLogPath, filePath)));
                return(new FileLogger(categoryName, fileWriter, _isFileLoggingEnabled, _isPrimary, LogType.Function, _scopeProvider));
            }

            // If it's not a supported category, we won't log anything from this provider.
            return(NullLogger.Instance);
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            IFileWriter writer;

            byte[] data = new byte[1024];

            if ("jpeg" == args[0])
            {
                writer = _jpegWriterFactory.Create();
            }
            else
            {
                writer = _pngWriterFactory.Create();
            }

            writer.Write(data, "lena");
        }