本文整理汇总了C#中Logger.Log方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Log方法的具体用法?C# Logger.Log怎么用?C# Logger.Log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clear
public void Clear() {
this.Head = null;
Contract.Memory.Rsd<Logger>(Contract.Memory.This, 1);
Contract.Memory.DestRsd(Contract.Memory.This);
Logger logger = new Logger();
logger.Log("Clear done");
}
示例2: PushFront
public void PushFront(Node node) {
Contract.Memory.Tmp<Logger>(1);
Contract.Memory.DestTmp();
Logger logger = new Logger();
node.Next = this.Head;
this.Head = node;
logger.Log("PushFront done");
}
示例3: Log_MessageNotEmpty_WriteCalledOnFileWriter
public void Log_MessageNotEmpty_WriteCalledOnFileWriter()
{
var mockedFileWriter = MockRepository.GenerateMock<IFileWriter>();
var logger = new Logger(mockedFileWriter);
const string message = "Message to be logged";
logger.Log(message);
mockedFileWriter.AssertWasCalled(writer => writer.Write(message));
}
示例4: Main
static void Main()
{
var logger = new Logger();
for (int i = 0; i < 500000; i++)
{
logger.Log(MethodBase.GetCurrentMethod(), LogLevel.Info, string.Format("Message"));
}
Console.WriteLine("Done");
Console.ReadKey();
}
示例5: Start
// Throws an exception on error.
public static void Start(int tcpPort, int udpPort, string logfilePath, VoxelData voxelData)
{
_logger = new Logger (logfilePath);
_voxelData = voxelData;
// open TCP listener
Socket serverSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
serverSocket.Bind (new IPEndPoint (IPAddress.Any, tcpPort));
serverSocket.Listen (0);
_logger.Log (string.Format ("TCP listening on {0}", Utils.IPAddressToString(serverSocket.LocalEndPoint)));
// open UDP listener
UdpClient serverUdpClient = new UdpClient (udpPort);
_logger.Log (string.Format ("UDP listening on {0}", Utils.IPAddressToString(serverUdpClient.Client.LocalEndPoint)));
// start accepting clients
Concurrency.StartThread (() => AcceptTcpClients (serverSocket), "server accept TCP clients loop", _logger);
// start broadcasting incoming UDP packets
Concurrency.StartThread (() => HandleUdp (serverUdpClient), "server broadcast UDP packets", _logger);
}
示例6: ObjectPool
public ObjectPool(Logger logger, GameObject prefab)
{
_objects = new List<PoolingBehaviour>();
_activeObjects = new List<PoolingBehaviour>();
_inactiveObjects = new List<PoolingBehaviour>();
// resolve references
_logger = logger;
_prefab = prefab;
if(_prefab.GetComponent<PoolingBehaviour>() == null)
_logger.Log("WARNING! ObjectPool built for non-pooling behaviour : " + _prefab.name);
}
示例7: ThenLogEventShouldHavePropertiesSet
public void ThenLogEventShouldHavePropertiesSet()
{
var context = new ValueComparison(null, null, null);
var logger = new Logger();
logger.Callback(x =>
{
x.Message.Should().Be("Hello, world!");
x.Level.Should().Be(LogLevel.Error);
x.Comparison.Should().NotBeNull();
});
logger.Log(LogLevel.Error, context, "Hello, {0}!", "world");
}
示例8: Logger_WhenLogLevelIsLower_ThenDoesNotLogOutput
public void Logger_WhenLogLevelIsLower_ThenDoesNotLogOutput()
{
// stores log output
string output = null;
var logger = new Logger
{
LogAction = s => output = s,
LogLevel = LogLevel.Information,
};
logger.Log("test", LogLevel.Verbose);
Assert.IsNull(output);
}
示例9: Logger_WhenLogLevelIsHigher_ThenLogsOutput
public void Logger_WhenLogLevelIsHigher_ThenLogsOutput()
{
// stores log output
string output = null;
var logger = new Logger
{
LogAction = s => output = s,
LogLevel = LogLevel.Verbose,
};
logger.Log("test", LogLevel.Information);
Assert.IsTrue(output.EndsWith("test"));
}
示例10: AcceptClientsAsync
static async void AcceptClientsAsync(Logger logger)
{
bool entered = false;
TcpClient client = null;
try
{
client = await _Listener.AcceptTcpClientAsync();
entered = true;
_Controller.ClientEntered();
AcceptClientsAsync(logger);
logger.Log("Client " + client.Client.RemoteEndPoint);
NetworkStream client_stream = client.GetStream();
// Get the request message
object request = await MessageUtils.RecvMsg(client_stream);
// Process the request message and send the response
await ProcessRequest(request, client_stream);
}
catch (SocketException ex)
{
logger.Log(String.Format("Server exception: {0}", ex));
}
catch (ObjectDisposedException) { }
catch (Exception ex)
{
logger.Log(String.Format("Server exception: {0}", ex));
}
finally
{
if (entered)
{
if (client != null)
try
{
(client as IDisposable).Dispose();
}
catch (ObjectDisposedException) { }
_Controller.ClientExiting();
}
}
}
示例11: Logger_WhenUsingDefaultFormat_ThenMatchesExpectedFormat
public void Logger_WhenUsingDefaultFormat_ThenMatchesExpectedFormat()
{
// stores log output
string output = null;
var logger = new Logger
{
LogAction = s => output = s,
LogLevel = LogLevel.Information,
};
logger.Log("test", LogLevel.Information);
// should match entries in the form of:
// "[MM/DD/YYYY HH:MM:SS (AM|PM)][Information][(category)] test"
const string pattern = @"\[[^\]]*\]\[Information\]\[[^\]]*\]\s.*";
Assert.IsTrue(Regex.IsMatch(output, pattern));
}
示例12: Logger_WhenUsingLoggerWithDebugStream_ThenOutputsToConsole
public void Logger_WhenUsingLoggerWithDebugStream_ThenOutputsToConsole()
{
var logger = new Logger
{
LogAction = s => Debug.WriteLine(s),
LogLevel = LogLevel.Information,
};
logger.Log("test", LogLevel.Information);
Assert.Inconclusive(
"This is a visual test. The test passed if you verify output in the following form: '[8/1/2012 9:19:08 PM][Information][] test'");
}
示例13: SubmitMsg
private void SubmitMsg()
{
Logger logger = new Logger(logFile);
logger.Log(startToken);
logger.Log("初始化SendMsgHelper");
SendMsgHelper helper = new SendMsgHelper
{
uidUser = Guid.Parse(uidUser),
logger = logger,
ImgsPath = Server.MapPath("~/UploadedImages/" + uidUser)
};
try
{
logger.Log("检查遗留任务");
if (helper.IsHasWaitingTasks())
{
logger.Log("发现之前还有未发送的信息!");
helper.ExecTask(profMsg);
logger.Log(completeToken);
return;
}
logger.Log("初始化任务数据库");
if (0 == helper.InitTask())
{
logger.Log(completeToken);
return;
}
logger.Log("初始化成功");
logger.Log("开始发送信息");
helper.ExecTask(profMsg);
logger.Log(completeToken);
}
catch (Exception ex)
{
//sw = new StreamWriter(logFile, true);
logger.Log(string.Format("系统异常:{0}", ex.ToString()));
logger.Log(completeToken);
//sw.Close();
return;
}
}
示例14: OnInit
protected override void OnInit(EventArgs e)
{
try
{
links = Links.Instance;
gui = GUIVariables.Instance;
dbOps = DBOperations.Instance;
categories = Categories.Instance;
log = Logger.Instance;
engine = ProcessingEngine.Instance;
general = General.Instance;
imageEngine = ImageEngine.Instance;
gui = GUIVariables.Instance;
itemDisplayer = ItemDisplayer.Instance;
if (Request != null)
{
if (!string.IsNullOrEmpty(Request.QueryString["category"]))
{
requestedTag = Request.QueryString["category"].Trim();
}
}
#region CookieAlreadyExists
// START: If a getputsCookie with the Username already exists, do not show the Login Page.
if (Request.Cookies["getputsCookie"] != null)
{
HttpCookie getputsCookie = Request.Cookies["getputsCookie"];
UID = dbOps.Decrypt(getputsCookie["UID"].ToString().Trim());
}
//TopAboutLabel.Text = "getputs is a utility for discovering, sharing and recommending user generated content."
// + gui.LineBreak
// + "Read/Post the latest/hottest news and classified submissions, ask queries, discuss your views!";
TopAboutLabel.Text = gui.GrayFontStart
+ "getputs is a utility for discovering, sharing, and recommending news."
+ gui.GrayFontEnd;
if (string.IsNullOrEmpty(UID))
{
TopAboutTable.Visible = true;
// If the Page is SLogin.aspx, then the LoginTable will not be visible.
// Else it is going to be visible in anycase.
// LoginTable.Visible = true;
UsernameTB.Focus();
Page.Form.DefaultButton = LoginButton.ID;
//LoginHL.Visible = true;
//RegisterHL.Visible = true;
// SubmitHL.Visible = false;
SubmitHL.Visible = true;
SavedHL.Visible = false;
UserAccountHL.Visible = false;
MyNewsHL.Visible = false;
LogoutHL.Visible = false;
UserWelcomeLabel.Text = "";
PostItDiv.Visible = true;
}
else
{
TopAboutTable.Visible = false;
LoginTable.Visible = false;
//LoginHL.Visible = false;
//RegisterHL.Visible = false;
SubmitHL.Visible = true;
SavedHL.Visible = true;
UserAccountHL.Visible = true;
MyNewsHL.Visible = true;
LogoutHL.Visible = true;
UserAccountHL.NavigateUrl = links.UserDetailsPageLink + "?UID=" + UID;
// UserWelcomeLabel.Text = gui.GrayFontStart + "Welcome " + UID + gui.GrayFontEnd;
UserWelcomeLabel.Text = gui.BoldFontStart + gui.GreenFontStart + "Welcome " + UID + gui.GreenFontEnd + gui.BoldFontEnd;
PostItDiv.Visible = false;
// Vatsal Shah | 2009-08-08 | LogVisitor() Throws a lot of errors. Thus commented for now.
// LogVisitor(UID);
}
// PopularCategoriesLabel.Visible = false;
// CategoryDiv.Visible = false;
// MoreHL.Visible = false;
// END: If a getputsCookie with the Username already exists, do not show the Login Page.
#endregion CookieAlreadyExists
//.........这里部分代码省略.........
示例15: Log
private static void Log(Logger logger, LogLevel level)
{
logger.Log(level, new ValueComparison(null, null, null), "Message");
}