本文整理汇总了C#中ErrorLog.Log方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorLog.Log方法的具体用法?C# ErrorLog.Log怎么用?C# ErrorLog.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorLog
的用法示例。
在下文中一共展示了ErrorLog.Log方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectionServer
public ConnectionServer( IPAddress addr, int port, MessageReceivedCallback callback, APPLICATION_DATA appData)
{
m_MessageReceviedCallback = callback;
m_ip_port = port;
m_IPAddr = addr;
m_AppData = appData;
m_Log = (ErrorLog)m_AppData.Logger;
string ViewerPassword;
string AdminPassword;
try
{
ViewerPassword = UserSettings.Get(UserSettingTags.PWLPRServiceViewer);
if (ViewerPassword == null) m_Log.Log("ViewerPW is null", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_Log.Log("viewer pw = " + ViewerPassword, ErrorLog.LOG_TYPE.INFORMATIONAL);
m_Log.Log("user path = " + UserSettings.GetAppPath(), ErrorLog.LOG_TYPE.INFORMATIONAL);
if (ViewerPassword == null)
ViewerPassword = " ";
else
ViewerPassword = Encryption.DecryptText(ViewerPassword);
AdminPassword = UserSettings.Get(UserSettingTags.PWLPRServiceAdmin);
if (AdminPassword == null)
AdminPassword = " ";
else
AdminPassword = Encryption.DecryptText(AdminPassword);
m_AppData.ServiceAdminPW = AdminPassword;
m_AppData.ServiceViewPW = ViewerPassword;
m_Clients = new List<ClientConnection>(); ;
listner = new TcpListener(addr, 13000);
listner.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);// this line is key, or else you get an exception because the OS does not release the socket if you re-start
listner.Start();
StartClientConnectWaitThread();
}
catch (Exception ex)
{
m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL);
Stop();
}
}
示例2: CanSpecifyCustomUrlOnErrorLog
public void CanSpecifyCustomUrlOnErrorLog()
{
// Arrange
var configUri = _fixture.Create<Uri>();
var errorLog = new ErrorLog(new Hashtable { { "LogId", _fixture.Create<Guid>().ToString() }, { "Url", configUri } });
// Act
errorLog.Log(new Error(new System.ApplicationException()));
// Assert
var client = ErrorLog.Client as Logger;
Assert.That(client != null);
Assert.That(client.Url, Is.EqualTo(configUri));
}
示例3: DoDefaultToAzureWhenNoUrlSpecified
public void DoDefaultToAzureWhenNoUrlSpecified()
{
// Arrange
Uri actualUri = null;
var webClientMock = new Mock<IWebClient>();
webClientMock
.Setup(x => x.Post(It.IsAny<WebHeaderCollection>(), It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<Func<WebHeaderCollection, string, string>>()))
.Callback<WebHeaderCollection, Uri, string, Func<WebHeaderCollection, string, string>>((headers, uri, data, resultor) => { actualUri = uri; })
.Returns(Task.FromResult(JsonConvert.SerializeObject(new { Id = _fixture.Create<string>() })));
var errorLog = new ErrorLog(new Hashtable { { "LogId", _fixture.Create<Guid>().ToString() } }, webClientMock.Object);
// Act
errorLog.Log(new Error(new System.ApplicationException()));
// Assert
Assert.That(actualUri.ToString(), Is.StringStarting("https://elmahio.azurewebsites.net/"));
}
示例4: CanSpecifyCustomUrlOnErrorLog
public void CanSpecifyCustomUrlOnErrorLog()
{
// Arrange
var configUri = _fixture.Create<Uri>();
Uri actualUri = null;
var webClientMock = new Mock<IWebClient>();
webClientMock
.Setup(x => x.Post(It.IsAny<WebHeaderCollection>(), It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<Func<WebHeaderCollection, string, string>>()))
.Callback<WebHeaderCollection, Uri, string, Func<WebHeaderCollection, string, string>>((headers, uri, data, resultor) => { actualUri = uri; })
.Returns(Task.FromResult(JsonConvert.SerializeObject(new { Id = _fixture.Create<string>() })));
var errorLog = new ErrorLog(new Hashtable { {"LogId", _fixture.Create<Guid>().ToString()}, {"Url", configUri} }, webClientMock.Object);
// Act
errorLog.Log(new Error(new System.ApplicationException()));
// Assert
Assert.That(actualUri.ToString(), Is.StringStarting(configUri.ToString()));
}
示例5: CanLogError
public void CanLogError()
{
// Arrange
var id = _fixture.Create<string>();
var logMessage = _fixture.Create<string>();
Message actualMessage = null;
var loggerMock = new Mock<ILogger>();
loggerMock
.Setup(x => x.BeginLog(It.IsAny<Message>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
.Callback<Message, AsyncCallback, object>((message, callback, state) => { actualMessage = message; })
.Returns(Task.FromResult(id));
var errorLog = new ErrorLog(loggerMock.Object);
// Act
var result = errorLog.Log(new Error(new System.ApplicationException(logMessage)));
// Assert
Assert.That(result, Is.EqualTo(id));
Assert.That(actualMessage, Is.Not.Null);
Assert.That(actualMessage.Title, Is.EqualTo(logMessage));
}
示例6: CanLogError
public void CanLogError()
{
var id = _fixture.Create<int>().ToString(CultureInfo.InvariantCulture);
var error = new { Id = id };
var logId = _fixture.Create<Guid>().ToString();
Uri actualUri = null;
string actualData = null;
var requestHeaders = new WebHeaderCollection();
var webClientMock = new Mock<IWebClient>();
webClientMock
.Setup(x => x.Post(It.IsAny<WebHeaderCollection>(), It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<Func<WebHeaderCollection, string, string>>()))
.Callback<WebHeaderCollection, Uri, string, Func<WebHeaderCollection, string, string>>((headers, uri, data, resultor) => { requestHeaders = headers; actualUri = uri; actualData = data; })
.Returns(Task.FromResult(JsonConvert.SerializeObject(error)));
var errorLog = new ErrorLog(new Hashtable { { "LogId", logId } }, webClientMock.Object);
var result = errorLog.Log(new Error(new System.ApplicationException()));
Assert.That(result, Is.EqualTo(id));
Assert.That(requestHeaders[HttpRequestHeader.ContentType], Is.EqualTo("application/x-www-form-urlencoded"));
Assert.That(actualUri.AbsoluteUri, Is.Not.Null.And.StringEnding(string.Format("api/errors?logId={0}", logId)));
Assert.That(actualData, Is.Not.Null.And.StringStarting("=").And.StringContaining("ApplicationException"));
}
示例7: DriveManager
// /////////////////
//
// design
//
// at startup, count how many external drives are available - there should only be one.
//
// if one drive, select that drive and create the default storage directory
// then inform the DVR function that a drive has been found and is ready
//
// setup a function to watch for changes in connected drives
// if a new drive is added, start the hotswap switch over, expect the previous drive to be disconnected
// if the currently selected drive is disconnected, notify the DVR the primary drive was lost
// if no drives are available, watch for new ones to be added, if one is added make it the primary.
public DriveManager(APPLICATION_DATA appData, OnDriveChangeEvent callback, string defaultStorageDir )
{
try
{
m_AppData = appData;
m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
m_Log = (ErrorLog)m_AppData.Logger;
OnDriveChange = callback;
m_DefaultStorageDirectory = defaultStorageDir;
singleton = new object();
m_HotSwapStatusString = new ThreadSafeQueue<string>(20);
// make the list of current drives now that we are going into a active mode
m_DriveListAtStartup = Environment.GetLogicalDrives();// to be used later if a drive change is detected
// are we running as AnalystsWorkstation, and no repositories found? if so, then use user-config storage area instead
bool runDriveCheckLoop = true;
if ( ! m_AppData.RunninAsService)
{
string[] drives = GetAllFirstEvidenceDrives();
if ( drives == null) drives = new string[0];
if (drives.Length < 1)
{
// runDriveCheckLoop = false;
m_Log.Log("User App Path = " + Application.UserAppDataPath, ErrorLog.LOG_TYPE.INFORMATIONAL);
m_CentralRepositoryDrive = Application.UserAppDataPath.Split(':')[0]+ ":\\";
m_SelectedDrive = m_CentralRepositoryDrive;
m_Log.Log("dm setting central to " + m_CentralRepositoryDrive, ErrorLog.LOG_TYPE.INFORMATIONAL);
RunDelayedDriveChangeNoticeThread();// run the new drive notify after this constructor completes execution
}
}
// look for drive changes..
// SetupDriveWatcher(); // USB events do not always fire correctly when hubs are used on certain computers
if ( runDriveCheckLoop)
StartPollForDriveChangesThread();
}
catch (Exception ex)
{
m_Log.Log("DriveManager ex: " + ex.Message, ErrorLog.LOG_TYPE.FATAL);
}
}
示例8: DVR
// constructor
public DVR(APPLICATION_DATA appData)
{
try
{
m_AppData = appData;
m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
m_Log = (ErrorLog)m_AppData.Logger;
PauseFlag = new PAUSE_FLAG();
PauseFlag.Pause = true;
FileAccessControl = new FILE_SYSTEM_ACCESS(PauseFlag, m_AppData);
try
{
Paths = new PATHS(m_AppData.ThisComputerName, true, m_AppData);
m_AppData.PathManager = (object)Paths;
}
catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
m_EventLogFile = new EventLogFiles.EventLogFiles(m_AppData);
// PRE MOTION BUFFER LENGHT
m_NumberOfFramesToPrePostBuffer = 30; // this many frames before and after moton event, if too small, files may be erased before motion is detected because of processing lag
////////
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveName].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveReady].boolean.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_FreeSpace].SnapshotDouble.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_UsedSpace].SnapshotDouble.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveHotSwap].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.SetValue = "No drive ";
m_FrameGenerator = (FrameGenerator)m_AppData.FrameGenerator;
m_DriveManager = new DriveManager(m_AppData, OnExternalDriveChange, Paths.StorageDir);
// alway use external storage
if ( m_AppData.RunninAsService)
{
int count = 0;
Paths.Drive = m_DriveManager.GetDrive(ref count);
PauseFlag.DriveExists = true;
if (count > 1)
{
PauseFlag.Pause = true;
m_Log.Log("Too many external drives on start", ErrorLog.LOG_TYPE.FATAL);
//m_MessageBoxMessage = "Too many external drives on start. Please connect only one external drive and re-start the LPR Service.";
//RunMessageBoxDialog();
}
else if (Paths.Drive == null)
{
PauseFlag.Pause = true;
m_Log.Log("External Drive not found", ErrorLog.LOG_TYPE.FATAL);
// m_MessageBoxMessage = "External drive not found. Please connect one external drive";
PauseFlag.DriveExists = false;
// RunMessageBoxDialog();
}
}
m_ConsumerID = m_FrameGenerator.GetNewConsumerID();
m_NewFrameQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_NewFrameQ", m_AppData);
m_MotionDetectedQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_MotionDetectedQ", m_AppData);
m_DirectyToStorageQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_DirectyToStorageQ", m_AppData);
m_NewLPRRecordQ = new ThreadSafeQueue<FRAME>(m_LPRRecordQueLen, "QueueOverruns_DVR_NewLPRRecordQ", m_AppData);
m_TempFileList = new ThreadSafeList<TEMPFILES>(120);
m_NumSourceChannels = (m_AppData.RunninAsService) ? m_AppData.MAX_PHYSICAL_CHANNELS : m_AppData.MAX_VIRTUAL_CHANNELS;
m_PreMotionRecords = new PRE_MOTION_RECORDS[m_NumSourceChannels];
m_DVRLoopThread = new Thread(DVRLoop);
m_ReportDVRStats = new Thread(ReportDVRStatusLoop);
m_TempFileCleanUpThread = new Thread(TempFilesCleanUpLoop);
m_MaintainFileSystemSizeLimit = new Thread(MaintainFileSystemSizeLimitLoop);
}
catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
}
示例9: Start
public void Start(bool AsService)
{
try
{
m_AppData.RunninAsService = AsService;
//////////////////////////////////////
//
// setup system wide health statistics
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_GPS].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Hotswap].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Service].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel1].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel2].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel3].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel4].StatString.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_DirectyToStorageQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_MotionDetectedQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_NewFrameQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_NewLPRRecordQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_FG_AllFramesConsumerPushQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_FG_MotionDetectedConsumerPushQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_FG_MotionDetectionQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_LPR_LPRFinalPlateGroupOutputQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_LPR_LPRPerFrameReadingQ].Accumulator.RegisterForUse(true);
m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_LPR_LPRProcessQ].Accumulator.RegisterForUse(true);
//////////////////////////////////////
//
// start error reporting lib ( decides if local and/or remote reporting)
m_AppData.Logger = new ErrorLog(m_AppData);
m_Log = (ErrorLog)m_AppData.Logger;
m_Log.Log("Starting LPR Services", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_Log.Log("using file in path: " + UserSettings.GetAppPath(), ErrorLog.LOG_TYPE.INFORMATIONAL);
//////////////////////////////////////
//
// start email lib (used by error reporting lib for remote error notifications and by the watch list processor)
m_Log.Log("Loading Email module", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_AppData.EmailServices = new EmailServices(m_AppData);
m_Email = (EmailServices)m_AppData.EmailServices;
//////////////////////////////////////
//
// load the Frame Generator
m_Log.Log("Loading Frame Generator module", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_AppData.FrameGenerator = (object)new FrameGenerator(m_AppData, AsService);
//////////////////////////////////////
//
// load the DVR
m_AppData.DVRMode = APPLICATION_DATA.DVR_MODE.STORE_ON_MOTION;
m_Log.Log("Loading DVR module", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_DVR = new DVR(m_AppData);
m_AppData.DVR = (object)m_DVR;
//////////////////////////////////////
//
// start the TCP Server
if (m_AppData.RunninAsService)
{
m_Log.Log("Loading TCP module", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_RCServer = new RemoteConnectionServer.RemoteConnectionServer(m_AppData);
}
//////////////////////////////////////
//
// load the LPR Engine
m_Log.Log("Loading LPR Engine", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_LPREngine = new LPREngine(m_AppData);
m_AppData.LPREngine = m_LPREngine;
//////////////////////////////////////
//
// load the Watch List Processor
m_Log.Log("Loading Watch List module", ErrorLog.LOG_TYPE.INFORMATIONAL);
m_WatchList = new WatchLists(m_AppData);
// now that all modules are loaded, let them register with each other for event communications
m_Log.Log("Starting registrations", ErrorLog.LOG_TYPE.INFORMATIONAL);
if (m_AppData.RunninAsService)
{
m_RCServer.StartRegistration();
}
m_DVR.StartRegistration();
//.........这里部分代码省略.........