@ -48,13 +48,11 @@ using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Chapters ;
using MediaBrowser.Controller.Collections ;
using MediaBrowser.Controller.Configuration ;
using MediaBrowser.Controller.Connect ;
using MediaBrowser.Controller.Devices ;
using MediaBrowser.Controller.Dlna ;
using MediaBrowser.Controller.Drawing ;
using MediaBrowser.Controller.Dto ;
using MediaBrowser.Controller.Entities ;
using MediaBrowser.Controller.IO ;
using MediaBrowser.Controller.Library ;
using MediaBrowser.Controller.LiveTv ;
using MediaBrowser.Controller.MediaEncoding ;
@ -80,7 +78,6 @@ using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Events ;
using MediaBrowser.Model.Globalization ;
using MediaBrowser.Model.IO ;
using MediaBrowser.Model.Logging ;
using MediaBrowser.Model.MediaInfo ;
using MediaBrowser.Model.Net ;
using MediaBrowser.Model.News ;
@ -117,6 +114,7 @@ using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certif
using MediaBrowser.Controller.Authentication ;
using System.Diagnostics ;
using ServiceStack.Text.Jsv ;
using Microsoft.Extensions.Logging ;
namespace Emby.Server.Implementations
{
@ -202,10 +200,10 @@ namespace Emby.Server.Implementations
public IPlugin [ ] Plugins { get ; protected set ; }
/// <summary>
/// Gets or sets the log manager .
/// Gets or sets the log ger factory .
/// </summary>
/// <value>The log manager .</value>
public ILog Mana ger Log Mana ger { get ; protected set ; }
/// <value>The log ger factory .</value>
public ILog gerFactory Log gerFactory { get ; protected set ; }
/// <summary>
/// Gets the application paths.
@ -275,12 +273,12 @@ namespace Emby.Server.Implementations
/// <returns>IConfigurationManager.</returns>
protected IConfigurationManager GetConfigurationManager ( )
{
return new ServerConfigurationManager ( ApplicationPaths , Log Mana ger, XmlSerializer , FileSystemManager ) ;
return new ServerConfigurationManager ( ApplicationPaths , Log gerFactory , XmlSerializer , FileSystemManager ) ;
}
protected virtual IResourceFileManager CreateResourceFileManager ( )
{
return new ResourceFileManager ( HttpResultFactory , Log Manager. Get Logger( "ResourceManager" ) , FileSystemManager ) ;
return new ResourceFileManager ( HttpResultFactory , Log gerFactory. Create Logger( "ResourceManager" ) , FileSystemManager ) ;
}
/// <summary>
@ -391,7 +389,7 @@ namespace Emby.Server.Implementations
/// Initializes a new instance of the <see cref="ApplicationHost" /> class.
/// </summary>
public ApplicationHost ( ServerApplicationPaths applicationPaths ,
ILog Mana ger log Mana ger,
ILog gerFactory log gerFactory ,
StartupOptions options ,
IFileSystem fileSystem ,
IPowerManagement powerManagement ,
@ -405,7 +403,7 @@ namespace Emby.Server.Implementations
// hack alert, until common can target .net core
BaseExtensions . CryptographyProvider = CryptographyProvider ;
XmlSerializer = new MyXmlSerializer ( fileSystem , log Manager. Get Logger( "XmlSerializer" ) ) ;
XmlSerializer = new MyXmlSerializer ( fileSystem , log gerFactory. Create Logger( "XmlSerializer" ) ) ;
NetworkManager = networkManager ;
networkManager . LocalSubnetsFn = GetConfiguredLocalSubnets ;
@ -413,13 +411,13 @@ namespace Emby.Server.Implementations
SystemEvents = systemEvents ;
ApplicationPaths = applicationPaths ;
Log Mana ger = log Mana ger;
Log gerFactory = log gerFactory ;
FileSystemManager = fileSystem ;
ConfigurationManager = GetConfigurationManager ( ) ;
// Initialize this early in case the -v command line option is used
Logger = Log Manager. Get Logger( "App" ) ;
Logger = Log gerFactory. Create Logger( "App" ) ;
StartupOptions = options ;
ReleaseAssetFilename = releaseAssetFilename ;
@ -427,7 +425,7 @@ namespace Emby.Server.Implementations
ImageEncoder = imageEncoder ;
SetBaseExceptionMessage ( ) ;
//SetBaseExceptionMessage() ;
fileSystem . AddShortcutHandler ( new MbLinkShortcutHandler ( fileSystem ) ) ;
@ -480,7 +478,7 @@ namespace Emby.Server.Implementations
{
if ( _deviceId = = null )
{
_deviceId = new DeviceId ( ApplicationPaths , Log Manager. Get Logger( "SystemId" ) , FileSystemManager ) ;
_deviceId = new DeviceId ( ApplicationPaths , Log gerFactory. Create Logger( "SystemId" ) , FileSystemManager ) ;
}
return _deviceId . Value ;
@ -545,7 +543,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException( "Error creating {0}" , ex , type . FullName ) ;
Logger . LogError( ex , "Error creating {type}" , type . FullName ) ;
// Don't blow up in release mode
return null ;
}
@ -625,7 +623,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException( "Error loading assembly {0}" , ex , file ) ;
Logger . LogError( ex , "Error loading assembly {file}" , file ) ;
return null ;
}
}
@ -648,7 +646,7 @@ namespace Emby.Server.Implementations
/// <typeparam name="T"></typeparam>
/// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
/// <returns>IEnumerable{``0}.</returns>
public IEnumerable < T > GetExports < T > ( bool manageLif time = true )
public IEnumerable < T > GetExports < T > ( bool manageLif e time = true )
{
var parts = GetExportTypes < T > ( )
. Select ( CreateInstanceSafe )
@ -656,7 +654,7 @@ namespace Emby.Server.Implementations
. Cast < T > ( )
. ToList ( ) ;
if ( manageLif time)
if ( manageLif e time)
{
lock ( DisposableParts )
{
@ -667,7 +665,7 @@ namespace Emby.Server.Implementations
return parts ;
}
public List < Tuple < T , string > > GetExportsWithInfo < T > ( bool manageLif time = true )
public List < Tuple < T , string > > GetExportsWithInfo < T > ( bool manageLif e time = true )
{
var parts = GetExportTypes < T > ( )
. Select ( i = >
@ -683,7 +681,7 @@ namespace Emby.Server.Implementations
. Where ( i = > i ! = null )
. ToList ( ) ;
if ( manageLif time)
if ( manageLif e time)
{
lock ( DisposableParts )
{
@ -694,6 +692,8 @@ namespace Emby.Server.Implementations
return parts ;
}
// TODO: @bond
/ *
private void SetBaseExceptionMessage ( )
{
var builder = GetBaseExceptionMessage ( ApplicationPaths ) ;
@ -701,8 +701,8 @@ namespace Emby.Server.Implementations
builder . Insert ( 0 , string . Format ( "Version: {0}{1}" , ApplicationVersion , Environment . NewLine ) ) ;
builder . Insert ( 0 , "*** Error Report ***" + Environment . NewLine ) ;
Log Mana ger. ExceptionMessagePrefix = builder . ToString ( ) ;
}
Log gerFactory . ExceptionMessagePrefix = builder . ToString ( ) ;
} * /
/// <summary>
/// Runs the startup tasks.
@ -726,20 +726,20 @@ namespace Emby.Server.Implementations
// }
//}
Logger . Info( "ServerId: {0}" , SystemId ) ;
Logger . Log Information ( "ServerId: {0}" , SystemId ) ;
var entryPoints = GetExports < IServerEntryPoint > ( ) .ToList ( ) ;
var entryPoints = GetExports < IServerEntryPoint > ( ) ;
RunEntryPoints ( entryPoints , true ) ;
Logger . Info( "Core startup complete" ) ;
Logger . Log Information ( "Core startup complete" ) ;
HttpServer . GlobalResponse = null ;
Logger . Info( "Post-init migrations complete" ) ;
Logger . Log Information ( "Post-init migrations complete" ) ;
RunEntryPoints ( entryPoints , false ) ;
Logger . Info( "All entry points have started" ) ;
Logger . Log Information ( "All entry points have started" ) ;
LogManager . RemoveConsoleOutput ( ) ;
//LoggerFactory.RemoveConsoleOutput() ;
}
private void RunEntryPoints ( IEnumerable < IServerEntryPoint > entryPoints , bool isBeforeStartup )
@ -752,7 +752,7 @@ namespace Emby.Server.Implementations
}
var name = entryPoint . GetType ( ) . FullName ;
Logger . Info( "Starting entry point {0}" , name ) ;
Logger . Log Information ( "Starting entry point {0}" , name ) ;
var now = DateTime . UtcNow ;
try
{
@ -760,9 +760,9 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException( "Error in {0}" , ex , name ) ;
Logger . LogError( ex , "Error in {name}" , name ) ;
}
Logger . Info( "Entry point completed: {0}. Duration: {1} seconds" , name , ( DateTime . UtcNow - now ) . TotalSeconds . ToString ( CultureInfo . InvariantCulture ) , "ImageInfos" ) ;
Logger . Log Information ( "Entry point completed: {0}. Duration: {1} seconds" , name , ( DateTime . UtcNow - now ) . TotalSeconds . ToString ( CultureInfo . InvariantCulture ) , "ImageInfos" ) ;
}
}
@ -777,13 +777,13 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error configuring autorun" , ex ) ;
Logger . Log Error( ex , "Error configuring autorun" ) ;
}
}
private IJsonSerializer CreateJsonSerializer ( )
{
return new JsonSerializer ( FileSystemManager , Log Manager. Get Logger( "JsonSerializer" ) ) ;
return new JsonSerializer ( FileSystemManager , Log gerFactory. Create Logger( "JsonSerializer" ) ) ;
}
public void Init ( )
@ -801,11 +801,7 @@ namespace Emby.Server.Implementations
JsonSerializer = CreateJsonSerializer ( ) ;
OnLoggerLoaded ( true ) ;
LogManager . LoggerLoaded + = ( s , e ) = > OnLoggerLoaded ( false ) ;
LogManager . LogSeverity = ConfigurationManager . CommonConfiguration . EnableDebugLevelLogging
? LogSeverity . Debug
: LogSeverity . Info ;
//LoggerFactory.LoggerLoaded += (s, e) => OnLoggerLoaded(false);
DiscoverTypes ( ) ;
@ -818,7 +814,7 @@ namespace Emby.Server.Implementations
protected virtual void OnLoggerLoaded ( bool isFirstLoad )
{
Logger . Info( "Application version: {0}" , ApplicationVersion ) ;
Logger . Log Information ( "Application version: {0}" , ApplicationVersion ) ;
if ( ! isFirstLoad )
{
@ -834,13 +830,13 @@ namespace Emby.Server.Implementations
pluginBuilder . AppendLine ( string . Format ( "{0} {1}" , plugin . Name , plugin . Version ) ) ;
}
Logger . Log Multiline( "Plugins:" , LogSeverity . Info , pluginBuilder ) ;
Logger . Log Information( "Plugins: {plugins}" , pluginBuilder . ToString ( ) ) ;
}
}
protected virtual IHttpClient CreateHttpClient ( )
{
return new HttpClientManager . HttpClientManager ( ApplicationPaths , Log Manager. Get Logger( "HttpClient" ) , FileSystemManager , GetDefaultUserAgent ) ;
return new HttpClientManager . HttpClientManager ( ApplicationPaths , Log gerFactory. Create Logger( "HttpClient" ) , FileSystemManager , GetDefaultUserAgent ) ;
}
public static IStreamHelper StreamHelper { get ; set ; }
@ -858,7 +854,7 @@ namespace Emby.Server.Implementations
RegisterSingleInstance ( JsonSerializer ) ;
RegisterSingleInstance ( SystemEvents ) ;
RegisterSingleInstance ( Log Mana ger, false ) ;
RegisterSingleInstance ( Log gerFactory , false ) ;
RegisterSingleInstance ( Logger ) ;
RegisterSingleInstance ( EnvironmentInfo ) ;
@ -873,7 +869,7 @@ namespace Emby.Server.Implementations
IsoManager = new IsoManager ( ) ;
RegisterSingleInstance ( IsoManager ) ;
TaskManager = new TaskManager ( ApplicationPaths , JsonSerializer , Log Manager. Get Logger( "TaskManager" ) , FileSystemManager , SystemEvents ) ;
TaskManager = new TaskManager ( ApplicationPaths , JsonSerializer , Log gerFactory. Create Logger( "TaskManager" ) , FileSystemManager , SystemEvents ) ;
RegisterSingleInstance ( TaskManager ) ;
RegisterSingleInstance ( XmlSerializer ) ;
@ -890,21 +886,21 @@ namespace Emby.Server.Implementations
RegisterSingleInstance ( CryptographyProvider ) ;
SocketFactory = new SocketFactory ( Log Manager. Get Logger( "SocketFactory" ) ) ;
SocketFactory = new SocketFactory ( Log gerFactory. Create Logger( "SocketFactory" ) ) ;
RegisterSingleInstance ( SocketFactory ) ;
RegisterSingleInstance ( PowerManagement ) ;
SecurityManager = new PluginSecurityManager ( this , HttpClient , JsonSerializer , ApplicationPaths , Log Mana ger, FileSystemManager , CryptographyProvider ) ;
SecurityManager = new PluginSecurityManager ( this , HttpClient , JsonSerializer , ApplicationPaths , Log gerFactory , FileSystemManager , CryptographyProvider ) ;
RegisterSingleInstance ( SecurityManager ) ;
InstallationManager = new InstallationManager ( Log Manager. Get Logger( "InstallationManager" ) , this , ApplicationPaths , HttpClient , JsonSerializer , SecurityManager , ServerConfigurationManager , FileSystemManager , CryptographyProvider , PackageRuntime ) ;
InstallationManager = new InstallationManager ( Log gerFactory. Create Logger( "InstallationManager" ) , this , ApplicationPaths , HttpClient , JsonSerializer , SecurityManager , ServerConfigurationManager , FileSystemManager , CryptographyProvider , PackageRuntime ) ;
RegisterSingleInstance ( InstallationManager ) ;
ZipClient = new ZipClient ( FileSystemManager ) ;
RegisterSingleInstance ( ZipClient ) ;
HttpResultFactory = new HttpResultFactory ( Log Mana ger, FileSystemManager , JsonSerializer , CreateBrotliCompressor ( ) ) ;
HttpResultFactory = new HttpResultFactory ( Log gerFactory , FileSystemManager , JsonSerializer , CreateBrotliCompressor ( ) ) ;
RegisterSingleInstance ( HttpResultFactory ) ;
RegisterSingleInstance < IServerApplicationHost > ( this ) ;
@ -915,36 +911,36 @@ namespace Emby.Server.Implementations
IAssemblyInfo assemblyInfo = new AssemblyInfo ( ) ;
RegisterSingleInstance < IAssemblyInfo > ( assemblyInfo ) ;
LocalizationManager = new LocalizationManager ( ServerConfigurationManager , FileSystemManager , JsonSerializer , Log Manager. Get Logger( "LocalizationManager" ) , assemblyInfo , new TextLocalizer ( ) ) ;
LocalizationManager = new LocalizationManager ( ServerConfigurationManager , FileSystemManager , JsonSerializer , Log gerFactory. Create Logger( "LocalizationManager" ) , assemblyInfo , new TextLocalizer ( ) ) ;
StringExtensions . LocalizationManager = LocalizationManager ;
RegisterSingleInstance ( LocalizationManager ) ;
TextEncoding = new TextEncoding . TextEncoding ( FileSystemManager , Log Manager. Get Logger( "TextEncoding" ) , JsonSerializer ) ;
TextEncoding = new TextEncoding . TextEncoding ( FileSystemManager , Log gerFactory. Create Logger( "TextEncoding" ) , JsonSerializer ) ;
RegisterSingleInstance ( TextEncoding ) ;
BlurayExaminer = new BdInfoExaminer ( FileSystemManager , TextEncoding ) ;
RegisterSingleInstance ( BlurayExaminer ) ;
RegisterSingleInstance < IXmlReaderSettingsFactory > ( new XmlReaderSettingsFactory ( ) ) ;
UserDataManager = new UserDataManager ( Log Mana ger, ServerConfigurationManager , ( ) = > UserManager ) ;
UserDataManager = new UserDataManager ( Log gerFactory , ServerConfigurationManager , ( ) = > UserManager ) ;
RegisterSingleInstance ( UserDataManager ) ;
UserRepository = GetUserRepository ( ) ;
// This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it
RegisterSingleInstance ( UserRepository ) ;
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository ( Log Manager. Get Logger( "SqliteDisplayPreferencesRepository" ) , JsonSerializer , ApplicationPaths , FileSystemManager ) ;
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository ( Log gerFactory. Create Logger( "SqliteDisplayPreferencesRepository" ) , JsonSerializer , ApplicationPaths , FileSystemManager ) ;
DisplayPreferencesRepository = displayPreferencesRepo ;
RegisterSingleInstance ( DisplayPreferencesRepository ) ;
var itemRepo = new SqliteItemRepository ( ServerConfigurationManager , this , JsonSerializer , Log Manager. Get Logger( "SqliteItemRepository" ) , assemblyInfo , FileSystemManager , EnvironmentInfo , TimerFactory ) ;
var itemRepo = new SqliteItemRepository ( ServerConfigurationManager , this , JsonSerializer , Log gerFactory. Create Logger( "SqliteItemRepository" ) , assemblyInfo , FileSystemManager , EnvironmentInfo , TimerFactory ) ;
ItemRepository = itemRepo ;
RegisterSingleInstance ( ItemRepository ) ;
AuthenticationRepository = GetAuthenticationRepository ( ) ;
RegisterSingleInstance ( AuthenticationRepository ) ;
UserManager = new UserManager ( Log Manager. Get Logger( "UserManager" ) , ServerConfigurationManager , UserRepository , XmlSerializer , NetworkManager , ( ) = > ImageProcessor , ( ) = > DtoService , this , JsonSerializer , FileSystemManager , CryptographyProvider ) ;
UserManager = new UserManager ( Log gerFactory. Create Logger( "UserManager" ) , ServerConfigurationManager , UserRepository , XmlSerializer , NetworkManager , ( ) = > ImageProcessor , ( ) = > DtoService , this , JsonSerializer , FileSystemManager , CryptographyProvider ) ;
RegisterSingleInstance ( UserManager ) ;
LibraryManager = new LibraryManager ( this , Logger , TaskManager , UserManager , ServerConfigurationManager , UserDataManager , ( ) = > LibraryMonitor , FileSystemManager , ( ) = > ProviderManager , ( ) = > UserViewManager ) ;
@ -953,16 +949,16 @@ namespace Emby.Server.Implementations
var musicManager = new MusicManager ( LibraryManager ) ;
RegisterSingleInstance < IMusicManager > ( new MusicManager ( LibraryManager ) ) ;
LibraryMonitor = new LibraryMonitor ( Log Mana ger, TaskManager , LibraryManager , ServerConfigurationManager , FileSystemManager , TimerFactory , SystemEvents , EnvironmentInfo ) ;
LibraryMonitor = new LibraryMonitor ( Log gerFactory , TaskManager , LibraryManager , ServerConfigurationManager , FileSystemManager , TimerFactory , SystemEvents , EnvironmentInfo ) ;
RegisterSingleInstance ( LibraryMonitor ) ;
RegisterSingleInstance < ISearchEngine > ( ( ) = > new SearchEngine ( Log Mana ger, LibraryManager , UserManager ) ) ;
RegisterSingleInstance < ISearchEngine > ( ( ) = > new SearchEngine ( Log gerFactory , LibraryManager , UserManager ) ) ;
CertificateInfo = GetCertificateInfo ( true ) ;
Certificate = GetCertificate ( CertificateInfo ) ;
HttpServer = new HttpListenerHost ( this ,
Log Manager. Get Logger( "HttpServer" ) ,
Log gerFactory. Create Logger( "HttpServer" ) ,
ServerConfigurationManager ,
"web/index.html" ,
NetworkManager ,
@ -983,37 +979,37 @@ namespace Emby.Server.Implementations
var encryptionManager = new EncryptionManager ( ) ;
RegisterSingleInstance < IEncryptionManager > ( encryptionManager ) ;
DeviceManager = new DeviceManager ( AuthenticationRepository , JsonSerializer , LibraryManager , LocalizationManager , UserManager , FileSystemManager , LibraryMonitor , ServerConfigurationManager , Log Manager. Get Logger( "DeviceManager" ) , NetworkManager ) ;
DeviceManager = new DeviceManager ( AuthenticationRepository , JsonSerializer , LibraryManager , LocalizationManager , UserManager , FileSystemManager , LibraryMonitor , ServerConfigurationManager , Log gerFactory. Create Logger( "DeviceManager" ) , NetworkManager ) ;
RegisterSingleInstance ( DeviceManager ) ;
var newsService = new Emby . Server . Implementations . News . NewsService ( ApplicationPaths , JsonSerializer ) ;
RegisterSingleInstance < INewsService > ( newsService ) ;
MediaSourceManager = new MediaSourceManager ( ItemRepository , ApplicationPaths , LocalizationManager , UserManager , LibraryManager , Log Manager. Get Logger( "MediaSourceManager" ) , JsonSerializer , FileSystemManager , UserDataManager , TimerFactory , ( ) = > MediaEncoder ) ;
MediaSourceManager = new MediaSourceManager ( ItemRepository , ApplicationPaths , LocalizationManager , UserManager , LibraryManager , Log gerFactory. Create Logger( "MediaSourceManager" ) , JsonSerializer , FileSystemManager , UserDataManager , TimerFactory , ( ) = > MediaEncoder ) ;
RegisterSingleInstance ( MediaSourceManager ) ;
SubtitleManager = new SubtitleManager ( Log Manager. Get Logger( "SubtitleManager" ) , FileSystemManager , LibraryMonitor , MediaSourceManager , ServerConfigurationManager , LocalizationManager ) ;
SubtitleManager = new SubtitleManager ( Log gerFactory. Create Logger( "SubtitleManager" ) , FileSystemManager , LibraryMonitor , MediaSourceManager , ServerConfigurationManager , LocalizationManager ) ;
RegisterSingleInstance ( SubtitleManager ) ;
ProviderManager = new ProviderManager ( HttpClient , SubtitleManager , ServerConfigurationManager , LibraryMonitor , Log Mana ger, FileSystemManager , ApplicationPaths , ( ) = > LibraryManager , JsonSerializer ) ;
ProviderManager = new ProviderManager ( HttpClient , SubtitleManager , ServerConfigurationManager , LibraryMonitor , Log gerFactory , FileSystemManager , ApplicationPaths , ( ) = > LibraryManager , JsonSerializer ) ;
RegisterSingleInstance ( ProviderManager ) ;
DtoService = new DtoService ( Log Manager. Get Logger( "DtoService" ) , LibraryManager , UserDataManager , ItemRepository , ImageProcessor , ServerConfigurationManager , FileSystemManager , ProviderManager , ( ) = > ChannelManager , this , ( ) = > DeviceManager , ( ) = > MediaSourceManager , ( ) = > LiveTvManager ) ;
DtoService = new DtoService ( Log gerFactory. Create Logger( "DtoService" ) , LibraryManager , UserDataManager , ItemRepository , ImageProcessor , ServerConfigurationManager , FileSystemManager , ProviderManager , ( ) = > ChannelManager , this , ( ) = > DeviceManager , ( ) = > MediaSourceManager , ( ) = > LiveTvManager ) ;
RegisterSingleInstance ( DtoService ) ;
ChannelManager = new ChannelManager ( UserManager , DtoService , LibraryManager , Log Manager. Get Logger( "ChannelManager" ) , ServerConfigurationManager , FileSystemManager , UserDataManager , JsonSerializer , LocalizationManager , HttpClient , ProviderManager ) ;
ChannelManager = new ChannelManager ( UserManager , DtoService , LibraryManager , Log gerFactory. Create Logger( "ChannelManager" ) , ServerConfigurationManager , FileSystemManager , UserDataManager , JsonSerializer , LocalizationManager , HttpClient , ProviderManager ) ;
RegisterSingleInstance ( ChannelManager ) ;
SessionManager = new SessionManager ( UserDataManager , Log Manager. Get Logger( "SessionManager" ) , LibraryManager , UserManager , musicManager , DtoService , ImageProcessor , JsonSerializer , this , HttpClient , AuthenticationRepository , DeviceManager , MediaSourceManager , TimerFactory ) ;
SessionManager = new SessionManager ( UserDataManager , Log gerFactory. Create Logger( "SessionManager" ) , LibraryManager , UserManager , musicManager , DtoService , ImageProcessor , JsonSerializer , this , HttpClient , AuthenticationRepository , DeviceManager , MediaSourceManager , TimerFactory ) ;
RegisterSingleInstance ( SessionManager ) ;
var dlnaManager = new DlnaManager ( XmlSerializer , FileSystemManager , ApplicationPaths , Log Manager. Get Logger( "Dlna" ) , JsonSerializer , this , assemblyInfo ) ;
var dlnaManager = new DlnaManager ( XmlSerializer , FileSystemManager , ApplicationPaths , Log gerFactory. Create Logger( "Dlna" ) , JsonSerializer , this , assemblyInfo ) ;
RegisterSingleInstance < IDlnaManager > ( dlnaManager ) ;
CollectionManager = new CollectionManager ( LibraryManager , ApplicationPaths , LocalizationManager , FileSystemManager , LibraryMonitor , Log Manager. Get Logger( "CollectionManager" ) , ProviderManager ) ;
CollectionManager = new CollectionManager ( LibraryManager , ApplicationPaths , LocalizationManager , FileSystemManager , LibraryMonitor , Log gerFactory. Create Logger( "CollectionManager" ) , ProviderManager ) ;
RegisterSingleInstance ( CollectionManager ) ;
PlaylistManager = new PlaylistManager ( LibraryManager , FileSystemManager , LibraryMonitor , Log Manager. Get Logger( "PlaylistManager" ) , UserManager , ProviderManager ) ;
PlaylistManager = new PlaylistManager ( LibraryManager , FileSystemManager , LibraryMonitor , Log gerFactory. Create Logger( "PlaylistManager" ) , UserManager , ProviderManager ) ;
RegisterSingleInstance < IPlaylistManager > ( PlaylistManager ) ;
LiveTvManager = new LiveTvManager ( this , HttpClient , ServerConfigurationManager , Logger , ItemRepository , ImageProcessor , UserDataManager , DtoService , UserManager , LibraryManager , TaskManager , LocalizationManager , JsonSerializer , ProviderManager , FileSystemManager , SecurityManager , ( ) = > ChannelManager ) ;
@ -1022,12 +1018,12 @@ namespace Emby.Server.Implementations
UserViewManager = new UserViewManager ( LibraryManager , LocalizationManager , UserManager , ChannelManager , LiveTvManager , ServerConfigurationManager ) ;
RegisterSingleInstance ( UserViewManager ) ;
NotificationManager = new NotificationManager ( Log Mana ger, UserManager , ServerConfigurationManager ) ;
NotificationManager = new NotificationManager ( Log gerFactory , UserManager , ServerConfigurationManager ) ;
RegisterSingleInstance ( NotificationManager ) ;
RegisterSingleInstance < IDeviceDiscovery > ( new DeviceDiscovery ( Log Manager. Get Logger( "IDeviceDiscovery" ) , ServerConfigurationManager , SocketFactory , TimerFactory ) ) ;
RegisterSingleInstance < IDeviceDiscovery > ( new DeviceDiscovery ( Log gerFactory. Create Logger( "IDeviceDiscovery" ) , ServerConfigurationManager , SocketFactory , TimerFactory ) ) ;
ChapterManager = new ChapterManager ( LibraryManager , Log Manager. Get Logger( "ChapterManager" ) , ServerConfigurationManager , ItemRepository ) ;
ChapterManager = new ChapterManager ( LibraryManager , Log gerFactory. Create Logger( "ChapterManager" ) , ServerConfigurationManager , ItemRepository ) ;
RegisterSingleInstance ( ChapterManager ) ;
RegisterMediaEncoder ( assemblyInfo ) ;
@ -1037,7 +1033,7 @@ namespace Emby.Server.Implementations
var activityLogRepo = GetActivityLogRepository ( ) ;
RegisterSingleInstance ( activityLogRepo ) ;
RegisterSingleInstance < IActivityManager > ( new ActivityManager ( Log Manager. Get Logger( "ActivityManager" ) , activityLogRepo , UserManager ) ) ;
RegisterSingleInstance < IActivityManager > ( new ActivityManager ( Log gerFactory. Create Logger( "ActivityManager" ) , activityLogRepo , UserManager ) ) ;
var authContext = new AuthorizationContext ( AuthenticationRepository , UserManager ) ;
RegisterSingleInstance < IAuthorizationContext > ( authContext ) ;
@ -1046,14 +1042,14 @@ namespace Emby.Server.Implementations
AuthService = new AuthService ( UserManager , authContext , ServerConfigurationManager , SessionManager , NetworkManager ) ;
RegisterSingleInstance < IAuthService > ( AuthService ) ;
SubtitleEncoder = new MediaBrowser . MediaEncoding . Subtitles . SubtitleEncoder ( LibraryManager , Log Manager. Get Logger( "SubtitleEncoder" ) , ApplicationPaths , FileSystemManager , MediaEncoder , JsonSerializer , HttpClient , MediaSourceManager , ProcessFactory , TextEncoding ) ;
SubtitleEncoder = new MediaBrowser . MediaEncoding . Subtitles . SubtitleEncoder ( LibraryManager , Log gerFactory. Create Logger( "SubtitleEncoder" ) , ApplicationPaths , FileSystemManager , MediaEncoder , JsonSerializer , HttpClient , MediaSourceManager , ProcessFactory , TextEncoding ) ;
RegisterSingleInstance ( SubtitleEncoder ) ;
RegisterSingleInstance ( CreateResourceFileManager ( ) ) ;
displayPreferencesRepo . Initialize ( ) ;
var userDataRepo = new SqliteUserDataRepository ( Log Manager. Get Logger( "SqliteUserDataRepository" ) , ApplicationPaths , FileSystemManager ) ;
var userDataRepo = new SqliteUserDataRepository ( Log gerFactory. Create Logger( "SqliteUserDataRepository" ) , ApplicationPaths , FileSystemManager ) ;
SetStaticProperties ( ) ;
@ -1082,9 +1078,9 @@ namespace Emby.Server.Implementations
}
}
public static void LogEnvironmentInfo ( ILogger l ogger, IApplicationPaths appPaths , bool isStartup )
public static void LogEnvironmentInfo ( ILogger L ogger, IApplicationPaths appPaths , bool isStartup )
{
logger. LogMultiline ( "Emby" , LogSeverity . Info , GetBaseExceptionMessage ( appPaths ) ) ;
Logger. LogInformation ( "Jellyfin:\n{ex}" , GetBaseExceptionMessage ( appPaths ) . ToString ( ) ) ;
}
protected static StringBuilder GetBaseExceptionMessage ( IApplicationPaths appPaths )
@ -1103,17 +1099,6 @@ namespace Emby.Server.Implementations
builder . AppendLine ( string . Format ( "64-Bit OS: {0}" , Environment . Is64BitOperatingSystem ) ) ;
builder . AppendLine ( string . Format ( "64-Bit Process: {0}" , Environment . Is64BitProcess ) ) ;
builder . AppendLine ( string . Format ( "User Interactive: {0}" , Environment . UserInteractive ) ) ;
Type type = Type . GetType ( "Mono.Runtime" ) ;
if ( type ! = null )
{
MethodInfo displayName = type . GetMethod ( "GetDisplayName" , BindingFlags . NonPublic | BindingFlags . Static ) ;
if ( displayName ! = null )
{
builder . AppendLine ( "Mono: " + displayName . Invoke ( null , null ) ) ;
}
}
builder . AppendLine ( string . Format ( "Processor count: {0}" , Environment . ProcessorCount ) ) ;
builder . AppendLine ( string . Format ( "Program data path: {0}" , appPaths . ProgramDataPath ) ) ;
builder . AppendLine ( string . Format ( "Application directory: {0}" , appPaths . ProgramSystemPath ) ) ;
@ -1130,7 +1115,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error setting http limit" , ex ) ;
Logger . Log Error( ex , "Error setting http limit" ) ;
}
}
@ -1189,7 +1174,7 @@ namespace Emby.Server.Implementations
//localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
if ( ! localCert . HasPrivateKey )
{
Logger . Error( "No private key included in SSL cert {0}." , certificateLocation ) ;
Logger . Log Error( "No private key included in SSL cert {0}." , certificateLocation ) ;
return null ;
}
@ -1197,14 +1182,14 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException( "Error loading cert from {0}" , ex , certificateLocation ) ;
Logger . LogError( ex , "Error loading cert from {certificateLocation}" , certificateLocation ) ;
return null ;
}
}
private IImageProcessor GetImageProcessor ( )
{
return new ImageProcessor ( Log Manager. Get Logger( "ImageProcessor" ) , ServerConfigurationManager . ApplicationPaths , FileSystemManager , JsonSerializer , ImageEncoder , ( ) = > LibraryManager , TimerFactory , ( ) = > MediaEncoder ) ;
return new ImageProcessor ( Log gerFactory. Create Logger( "ImageProcessor" ) , ServerConfigurationManager . ApplicationPaths , FileSystemManager , JsonSerializer , ImageEncoder , ( ) = > LibraryManager , TimerFactory , ( ) = > MediaEncoder ) ;
}
protected virtual FFMpegInstallInfo GetFfmpegInstallInfo ( )
@ -1262,7 +1247,8 @@ namespace Emby.Server.Implementations
probePath = info . ProbePath ;
var hasExternalEncoder = string . Equals ( info . Version , "external" , StringComparison . OrdinalIgnoreCase ) ;
var mediaEncoder = new MediaBrowser . MediaEncoding . Encoder . MediaEncoder ( LogManager . GetLogger ( "MediaEncoder" ) ,
var mediaEncoder = new MediaBrowser . MediaEncoding . Encoder . MediaEncoder (
LoggerFactory . CreateLogger ( "MediaEncoder" ) ,
JsonSerializer ,
encoderPath ,
probePath ,
@ -1292,7 +1278,7 @@ namespace Emby.Server.Implementations
/// <returns>Task{IUserRepository}.</returns>
private IUserRepository GetUserRepository ( )
{
var repo = new SqliteUserRepository ( Log Manager. Get Logger( "SqliteUserRepository" ) , ApplicationPaths , JsonSerializer ) ;
var repo = new SqliteUserRepository ( Log gerFactory. Create Logger( "SqliteUserRepository" ) , ApplicationPaths , JsonSerializer ) ;
repo . Initialize ( ) ;
@ -1301,7 +1287,7 @@ namespace Emby.Server.Implementations
private IAuthenticationRepository GetAuthenticationRepository ( )
{
var repo = new AuthenticationRepository ( Log Manager. Get Logger( "AuthenticationRepository" ) , ServerConfigurationManager ) ;
var repo = new AuthenticationRepository ( Log gerFactory. Create Logger( "AuthenticationRepository" ) , ServerConfigurationManager ) ;
repo . Initialize ( ) ;
@ -1310,7 +1296,7 @@ namespace Emby.Server.Implementations
private IActivityRepository GetActivityLogRepository ( )
{
var repo = new ActivityRepository ( Log Manager. Get Logger( "ActivityRepository" ) , ServerConfigurationManager . ApplicationPaths , FileSystemManager ) ;
var repo = new ActivityRepository ( Log gerFactory. Create Logger( "ActivityRepository" ) , ServerConfigurationManager . ApplicationPaths , FileSystemManager ) ;
repo . Initialize ( ) ;
@ -1325,7 +1311,7 @@ namespace Emby.Server.Implementations
( ( SqliteItemRepository ) ItemRepository ) . ImageProcessor = ImageProcessor ;
// For now there's no real way to inject these properly
BaseItem . Logger = Log Manager. Get Logger( "BaseItem" ) ;
BaseItem . Logger = Log gerFactory. Create Logger( "BaseItem" ) ;
BaseItem . ConfigurationManager = ServerConfigurationManager ;
BaseItem . LibraryManager = LibraryManager ;
BaseItem . ProviderManager = ProviderManager ;
@ -1425,7 +1411,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException( "Error getting plugin Id from {0}." , ex , plugin . GetType ( ) . FullName ) ;
Logger . LogError( ex , "Error getting plugin Id from {pluginName}." , plugin . GetType ( ) . FullName ) ;
}
}
@ -1437,7 +1423,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException( "Error loading plugin {0}" , ex , plugin . GetType ( ) . FullName ) ;
Logger . LogError( ex , "Error loading plugin {pluginName}" , plugin . GetType ( ) . FullName ) ;
return null ;
}
@ -1449,7 +1435,7 @@ namespace Emby.Server.Implementations
/// </summary>
protected void DiscoverTypes ( )
{
Logger . Info( "Loading assemblies" ) ;
Logger . Log Information ( "Loading assemblies" ) ;
var assemblyInfos = GetComposablePartAssemblies ( ) ;
@ -1460,11 +1446,11 @@ namespace Emby.Server.Implementations
if ( path = = null )
{
Logger . Info( "Loading {0 }", assembly . FullName ) ;
Logger . LogInformation( "Loading {assemblyName }", assembly . FullName ) ;
}
else
{
Logger . Info( "Loading {0} from {1 }", assembly . FullName , path ) ;
Logger . LogInformation( "Loading {assemblyName} from {path }", assembly . FullName , path ) ;
}
}
@ -1506,7 +1492,7 @@ namespace Emby.Server.Implementations
{
if ( loaderException ! = null )
{
Logger . Error( "LoaderException: " + loaderException . Message ) ;
Logger . Log Error( "LoaderException: " + loaderException . Message ) ;
}
}
}
@ -1517,7 +1503,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error loading types from assembly" , ex ) ;
Logger . Log Error( ex , "Error loading types from assembly" ) ;
return new List < Tuple < Type , string > > ( ) ;
}
@ -1564,7 +1550,7 @@ namespace Emby.Server.Implementations
? "The http server is unable to start due to a Socket error. This can occasionally happen when the operating system takes longer than usual to release the IP bindings from the previous session. This can take up to five minutes. Please try waiting or rebooting the system."
: "Error starting Http Server" ;
Logger . ErrorException( msg , ex ) ;
Logger . LogError( ex , msg ) ;
if ( HttpPort = = ServerConfiguration . DefaultHttpPort )
{
@ -1580,7 +1566,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error starting http server" , ex ) ;
Logger . Log Error( ex , "Error starting http server" ) ;
throw ;
}
@ -1615,7 +1601,7 @@ namespace Emby.Server.Implementations
// }
// catch (Exception ex)
// {
// Logger. ErrorException ("Error creating ssl cert", ex );
// Logger. Log Error(ex, "Error creating ssl cert");
// return null;
// }
// }
@ -1672,7 +1658,7 @@ namespace Emby.Server.Implementations
if ( requiresRestart )
{
Logger . Info( "App needs to be restarted due to configuration change." ) ;
Logger . Log Information ( "App needs to be restarted due to configuration change." ) ;
NotifyPendingRestart ( ) ;
}
@ -1683,7 +1669,7 @@ namespace Emby.Server.Implementations
/// </summary>
public void NotifyPendingRestart ( )
{
Logger . Info( "App needs to be restarted." ) ;
Logger . Log Information ( "App needs to be restarted." ) ;
var changed = ! HasPendingRestart ;
@ -1720,10 +1706,10 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error sending server restart notification" , ex ) ;
Logger . Log Error( ex , "Error sending server restart notification" ) ;
}
Logger . Info( "Calling RestartInternal" ) ;
Logger . Log Information ( "Calling RestartInternal" ) ;
RestartInternal ( ) ;
} ) ;
@ -1849,13 +1835,13 @@ namespace Emby.Server.Implementations
{
var result = Version . Parse ( FileVersionInfo . GetVersionInfo ( path ) . FileVersion ) ;
Logger . Info( "File {0} has version {1}" , path , result ) ;
Logger . Log Information ( "File {0} has version {1}" , path , result ) ;
return result ;
}
catch ( Exception ex )
{
Logger . ErrorException( "Error getting version number from {0}" , ex , path ) ;
Logger . LogError( ex , "Error getting version number from {path}" , path ) ;
return new Version ( 1 , 0 ) ;
}
@ -1940,13 +1926,13 @@ namespace Emby.Server.Implementations
if ( version < minRequiredVersion )
{
Logger . Info( "Not loading {0} {1} because the minimum supported version is {2 }. Please update to the newer version", filename , version , minRequiredVersion ) ;
Logger . LogInformation( "Not loading {filename} {version} because the minimum supported version is {minRequiredVersion }. Please update to the newer version", filename , version , minRequiredVersion ) ;
return false ;
}
}
catch ( Exception ex )
{
Logger . ErrorException( "Error getting version number from {0}" , ex , path ) ;
Logger . LogError( ex , "Error getting version number from {path}" , path ) ;
return false ;
}
@ -1962,6 +1948,7 @@ namespace Emby.Server.Implementations
public async Task < SystemInfo > GetSystemInfo ( CancellationToken cancellationToken )
{
var localAddress = await GetLocalApiUrl ( cancellationToken ) . ConfigureAwait ( false ) ;
var wanAddress = await GetWanApiUrl ( cancellationToken ) . ConfigureAwait ( false ) ;
return new SystemInfo
{
@ -1984,8 +1971,7 @@ namespace Emby.Server.Implementations
CanSelfRestart = CanSelfRestart ,
CanSelfUpdate = CanSelfUpdate ,
CanLaunchWebBrowser = CanLaunchWebBrowser ,
// TODO - remove WanAddress
WanAddress = "0.0.0.0" ,
WanAddress = wanAddress ,
HasUpdateAvailable = HasUpdateAvailable ,
SupportsAutoRunAtStartup = SupportsAutoRunAtStartup ,
TranscodingTempPath = ApplicationPaths . TranscodingTempPath ,
@ -2012,14 +1998,13 @@ namespace Emby.Server.Implementations
public async Task < PublicSystemInfo > GetPublicSystemInfo ( CancellationToken cancellationToken )
{
var localAddress = await GetLocalApiUrl ( cancellationToken ) . ConfigureAwait ( false ) ;
var wanAddress = await GetWanApiUrl ( cancellationToken ) . ConfigureAwait ( false ) ;
return new PublicSystemInfo
{
Version = ApplicationVersion . ToString ( ) ,
Id = SystemId ,
OperatingSystem = EnvironmentInfo . OperatingSystem . ToString ( ) ,
// TODO - remove WanAddress
WanAddress = "0.0.0.0" ,
WanAddress = wanAddress ,
ServerName = FriendlyName ,
LocalAddress = localAddress
} ;
@ -2054,12 +2039,38 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error getting local Ip address information" , ex ) ;
Logger . Log Error( ex , "Error getting local Ip address information" ) ;
}
return null ;
}
public async Task < string > GetWanApiUrl ( CancellationToken cancellationToken )
{
var url = "http://ipv4.icanhazip.com" ;
try
{
using ( var response = await HttpClient . Get ( new HttpRequestOptions
{
Url = url ,
LogErrorResponseBody = false ,
LogErrors = false ,
LogRequest = false ,
TimeoutMs = 10000 ,
BufferContent = false ,
CancellationToken = cancellationToken
} ) )
{
return GetLocalApiUrl ( response . ReadToEnd ( ) . Trim ( ) ) ;
}
}
catch ( Exception ex )
{
Logger . LogError ( ex , "Error getting WAN Ip address information" ) ;
}
return null ;
}
public string GetLocalApiUrl ( IpAddressInfo ipAddress )
{
if ( ipAddress . AddressFamily = = IpAddressFamily . InterNetworkV6 )
@ -2185,19 +2196,19 @@ namespace Emby.Server.Implementations
var valid = string . Equals ( Name , result , StringComparison . OrdinalIgnoreCase ) ;
_validAddressResults . AddOrUpdate ( apiUrl , valid , ( k , v ) = > valid ) ;
Logger . Debug( "Ping test result to {0}. Success: {1}" , apiUrl , valid ) ;
Logger . Log Debug( "Ping test result to {0}. Success: {1}" , apiUrl , valid ) ;
return valid ;
}
}
}
catch ( OperationCanceledException )
{
Logger . Debug( "Ping test result to {0}. Success: {1}" , apiUrl , "Cancelled" ) ;
Logger . Log Debug( "Ping test result to {0}. Success: {1}" , apiUrl , "Cancelled" ) ;
throw ;
}
catch ( Exception ex )
{
Logger . Debug( "Ping test result to {0}. Success: {1} {2} ", apiUrl , fals e, ex . Messag e) ;
Logger . Log Debug( ex , "Ping test result to {0}. Success: {1} ", apiUrl , fals e) ;
_validAddressResults . AddOrUpdate ( apiUrl , false , ( k , v ) = > false ) ;
return false ;
@ -2236,7 +2247,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error sending server shutdown notification" , ex ) ;
Logger . Log Error( ex , "Error sending server shutdown notification" ) ;
}
ShutdownInternal ( ) ;
@ -2249,7 +2260,7 @@ namespace Emby.Server.Implementations
/// </summary>
private void RegisterServerWithAdministratorAccess ( )
{
Logger . Info( "Requesting administrative access to authorize http server" ) ;
Logger . Log Information ( "Requesting administrative access to authorize http server" ) ;
try
{
@ -2261,7 +2272,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error authorizing server" , ex ) ;
Logger . Log Error( ex , "Error authorizing server" ) ;
}
}
@ -2428,9 +2439,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Console . WriteLine ( "Error launching url: {0}" , url ) ;
Logger . ErrorException ( "Error launching url: {0}" , ex , url ) ;
Logger . LogError ( ex , "Error launching url: {url}" , url ) ;
throw ;
}
}
@ -2450,7 +2459,7 @@ namespace Emby.Server.Implementations
/// <param name="package">The package.</param>
protected void OnApplicationUpdated ( PackageVersionInfo package )
{
Logger . Info( "Application has been updated to version {0}" , package . versionStr ) ;
Logger . Log Information ( "Application has been updated to version {0}" , package . versionStr ) ;
EventHelper . FireEventIfNotNull ( ApplicationUpdated , this , new GenericEventArgs < PackageVersionInfo >
{
@ -2485,15 +2494,15 @@ namespace Emby.Server.Implementations
{
var type = GetType ( ) ;
LogManager . AddConsoleOutput ( ) ;
Logger . Info( "Disposing " + type . Name ) ;
//LoggerFactory.AddConsoleOutput() ;
Logger . Log Information ( "Disposing " + type . Name ) ;
var parts = DisposableParts . Distinct ( ) . Where ( i = > i . GetType ( ) ! = type ) . ToList ( ) ;
DisposableParts . Clear ( ) ;
foreach ( var part in parts )
{
Logger . Info( "Disposing " + part . GetType ( ) . Name ) ;
Logger . Log Information ( "Disposing " + part . GetType ( ) . Name ) ;
try
{
@ -2501,7 +2510,7 @@ namespace Emby.Server.Implementations
}
catch ( Exception ex )
{
Logger . ErrorException ( "Error disposing {0}" , ex , part . GetType ( ) . Name ) ;
Logger . Log Error( ex , "Error disposing {0}" , part . GetType ( ) . Name ) ;
}
}
}