本文整理汇总了C#中System.Logger.Log方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Log方法的具体用法?C# Logger.Log怎么用?C# Logger.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Logger
的用法示例。
在下文中一共展示了Logger.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public void Start()
{
try
{
retries = int.Parse(ConfigurationManager.AppSettings["Retries"]);
logger = LogManager.CreateLogger("Custom.LoggingWrapper.LogManager");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
return;
}
try
{
logger.Log(Level.DEBUG, "Starting Ignite Scheduled Email Creator...");
is_running = true;
// Note that there are two threads doing the processing. one for registration and one for sos calls
callsListener = new Thread(Listen);
callsListener.Start();
// expiryDateChecker.Start();
logger.Log(Level.DEBUG, "Ignite Scheduled Email Creator : started");
}
catch (Exception ex)
{
logger.Log(Level.ERROR, ex.ToString());
Stop();
}
}
示例2: MainForm
public MainForm()
{
InitializeComponent();
//general
this.button1.Tag = false;
this.button1.Enabled = false;
this.pboxVoiceStatus.Image = this.imageListVoiceStatus.Images[1];
this.label2.Text = "";
this.lblServerStatus.Text = "Disconneted";
this.tsddbSettings.AutoToolTip = false;
this._logger = new Logger(this.tbLog);
DataSet ds = new DataSet();
string s_file = "MessagesDB.xml";
try
{
_logger.Log(String.Format("Loading XML Data file: {0}...", s_file));
ds.ReadXml(s_file);
_logger.Log("XML Data file file loaded successfuly");
}
catch (Exception e)
{
_logger.Log(String.Format("Error in shcema loading: {0}. skipping.", e.Message));
}
grammer_completed_handler = new EventHandler<LoadGrammarCompletedEventArgs>(this.recognizer_LoadGrammarCompleted);
}
示例3: TransvoxelManager
public TransvoxelManager(GraphicsDevice gd)
{
_gd = gd;
_logger = Logger.GetLogger();
_chunks = new ConcurrentDictionary<Vector3, Chunk>();
// Initialize Transvoxel
_logSend = "TransvoxelManager";
_logger.Log(_logSend, "Creating Octree");
_volumeData = new HashedVolume<sbyte>();
_logger.Log(_logSend, "Creating TransvoxelExtractor");
_surfaceExtractor = new TransvoxelExtractor(_volumeData);
}
示例4: Main
static void Main(string[] args)
{
BaseLogger logger = new Logger();
//Log started
logger.Log("Log started");
//Base: Log Continuing
logger.Log("Base: Log Continuing");
//((BaseLogger)logger).Log("Log Continuing"); //=> Just prints: Log Continuing
//Finished
//logger.LogCompleted(); // => Completed
((Logger)logger).LogCompleted();
Console.ReadKey();
}
示例5: Execute
public void Execute()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "BMP (*.BMP)|*.BMP|JPEG (*.JPEG; *.JPG)|*.JPEG;*.JPG|All files (*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
Bitmap openedBitmap = (Bitmap)Bitmap.FromFile(openFileDialog.FileName);
_drawingFeatures.PaintingArea.Image = ConvertIndexedBitmapToNonIndexed(openedBitmap);
_drawingFeatures.Graphics = Graphics.FromImage(_drawingFeatures.PaintingArea.Image);
}
catch(Exception e)
{
_drawingFeatures.PaintingArea.Image = new Bitmap(1000, 1000);
_drawingFeatures.Graphics = Graphics.FromImage(_drawingFeatures.PaintingArea.Image);
MessageBox.Show("Could not open the file");
Logger logger = new Logger();
logger.Log(e);
}
finally
{
_drawingFeatures.DrawingHistory = new DrawingHistory();
}
}
}
示例6: CanLogMessage
public void CanLogMessage()
{
// Arrange
var id = _fixture.Create<int>().ToString(CultureInfo.InvariantCulture);
var logId = _fixture.Create<Guid>();
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("https://elmah.io/api/v2/messages?id=" + id + "&logid=" + logId));
var logger = new Logger(logId, null, webClientMock.Object);
var message = _fixture.Create<Message>();
// Act
var result = logger.Log(message);
// Assert
Assert.That(result, Is.EqualTo(id));
Assert.That(requestHeaders[HttpRequestHeader.ContentType], Is.EqualTo("application/json"));
Assert.That(actualUri.AbsoluteUri, Is.Not.Null.And.StringEnding(string.Format("api/v2/messages?logId={0}", logId)));
Assert.That(actualData, Is.Not.Null);
Assert.That(actualData, Is.StringContaining(message.Title));
Assert.That(actualData, Is.StringContaining(message.Severity.ToString()));
}
示例7: Test
public async Task Test()
{
var logger = new Logger(new ConsoleLogObserver(), new DefaultDateTimeProvider());
var consumers = new Dictionary<MessageQueue, Action<BasicDeliverEventArgs>>()
{
{
new MessageQueue("test"),
args =>
{
var body = args.Body;
var msg = Encoding.UTF8.GetString(body, 0, body.Length);
logger.Log("Received", new {msg});
}
}
};
var connectionFactory = new ConnectionFactory() { HostName = "amqp://localhost/" };
var provider = new RabbitMqService(connectionFactory, logger);
var cts = new CancellationTokenSource();
await provider.ConnectAsync(consumers, cts.Token, logger);
await provider.Send(new SendingMessage(new PublicationAddress("d", "test", ""), Encoding.UTF8.GetBytes("Hi! Test!")));
var tcs = new TaskCompletionSource<object>();
await tcs.Task;
}
示例8: Main
static void Main(string[] args)
{
string initpath = "./";
string outpath = "../bin/script02.CSLEDll.bytes";
var logger = new Logger();
ScriptEnv.Instance.Reset(logger);
logger.Log_Warn("Begin Script Test.");
string scriptpath = System.IO.Path.GetFullPath(initpath);//需要修改
logger.Log("ScriptPath=" + scriptpath);
logger.Log_Warn("Please Check if the path is correct.Press any key to continue.");
logger.Pause();
string[] filelist = System.IO.Directory.GetFiles(scriptpath, "*.cs", System.IO.SearchOption.AllDirectories);
logger.Log_Warn("got code file:" + filelist.Length);
logger.Log_Warn("BeginTokenParse");
Dictionary<string, IList<CSLE.Token>> project = new Dictionary<string, IList<CSLE.Token>>();
foreach (var f in filelist)
{
string code = System.IO.File.ReadAllText(f);
var tokens = ScriptEnv.Instance.scriptEnv.tokenParser.Parse(code);
var filename = System.IO.Path.GetFileName(f);
project[filename] = tokens;
logger.Log("TokenParse:" + filename + " len:" + code.Length + " token:" + tokens.Count);
}
logger.Log_Warn("TokenParser Finish.");
logger.Log_Warn("BeginCompile");
ScriptEnv.Instance.scriptEnv.Project_Compiler(project, true);
logger.Log_Warn("EndCompile");
using (System.IO.Stream s = System.IO.File.Open(outpath, System.IO.FileMode.Create))
{
ScriptEnv.Instance.scriptEnv.Project_PacketToStream(project, s);
}
logger.Log("Write script.CSLEDll.bytes in:" + outpath);
logger.Log_Warn("Test end.Press any key to exit.");
logger.Pause();
}
示例9: CreateADrawableObject
public ADrawable CreateADrawableObject(IDrawingFeatures drawingFeatures, Point startPoint)
{
switch (drawingFeatures.DrawingState)
{
case DrawingState.DrawCircle:
{
ADrawable draw = new CircleDrawer(drawingFeatures, startPoint);
return draw;
}
case DrawingState.DrawRectangle:
{
ADrawable draw = new RectangleDrawer(drawingFeatures, startPoint);
return draw;
}
case DrawingState.DrawFilledCircle:
{
ADrawable draw = new FillCircleDrawer(drawingFeatures, startPoint);
return draw;
}
case DrawingState.DrawFilledRectangle:
{
ADrawable draw = new FillRectangleDrawer(drawingFeatures, startPoint);
return draw;
}
case DrawingState.DrawLine:
{
ADrawable draw = new LineDrawer(drawingFeatures, startPoint);
return draw;
}
case DrawingState.DrawPencil:
{
ADrawable draw = new PencilDrawer(drawingFeatures);
return draw;
}
case DrawingState.FloodFill:
{
ADrawable draw = new FloodFill(drawingFeatures, startPoint);
return draw;
}
default:
{
ADrawable draw = new NullDrawer();
Logger logger = new Logger();
logger.Log(new ArgumentException("DrawableFactory - Drawing State: "+drawingFeatures.DrawingState.ToString()));
return draw;
}
}
}
示例10: CreateIMenuCommnadObject
public IMenuCommand CreateIMenuCommnadObject(IDrawingFeatures drawingFeatures, string menuCommandName)
{
switch (menuCommandName)
{
case "New":
{
IMenuCommand menuCommnad = new NewCommand(drawingFeatures);
return menuCommnad;
}
case "Open":
{
IMenuCommand menuCommnad = new OpenCommand(drawingFeatures);
return menuCommnad;
}
case "Save":
{
IMenuCommand menuCommnad = new SaveCommand(drawingFeatures);
return menuCommnad;
}
case "Undo":
{
IMenuCommand menuCommnad = new UndoCommand(drawingFeatures);
return menuCommnad;
}
case "Redo":
{
IMenuCommand menuCommnad = new RedoCommand(drawingFeatures);
return menuCommnad;
}
case "Resize":
{
IMenuCommand menuCommnad = new ResizePaintingAreaCommand(drawingFeatures);
return menuCommnad;
}
default:
{
IMenuCommand menuCommnad = new NullMenuCommand();
Logger logger = new Logger();
logger.Log(new ArgumentException("MenuCommandFactory - MenuCommandName: " + menuCommandName));
return menuCommnad;
}
}
}
示例11: Planet
/// <summary>
/// parset planetinformationen
/// </summary>
/// <param name="planetNode">Html Knoten, der die Planetinformationen enthält</param>
public Planet(HtmlAgilityPack.HtmlNode planetNode, StringManager strings, Logger logger)
{
logger.Log (LoggingCategories.Parse, "Planet Constructor");
this._name = planetNode.SelectSingleNode (strings.PlanetNameXPath).InnerText;
//Koordinaten auslesen:
string coordsString = planetNode.SelectSingleNode (strings.PlanetCoordsXPath).InnerText;
System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match (coordsString, strings.PlanetCoordsRegex);
//Koordinaten Parsen
this._coords.Galaxy = Convert.ToInt32 (match.Groups [1].Value);
this._coords.SunSystem = Convert.ToInt32 (match.Groups [2].Value);
this._coords.Place = Convert.ToInt32 (match.Groups [3].Value);
//Link auslesen:
string linktToPlanet = planetNode.SelectSingleNode (strings.PlanetLinkXPath).Attributes ["href"].Value;
this._id = Utils.StringReplaceToInt32 (Utils.SimpleRegex (linktToPlanet, strings.PlanetIDRegex));
}
示例12: Execute
public void Execute()
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "BMP (*.BMP)|*.BMP|JPEG (*.JPEG; *.JPG)|*.JPEG;*.JPG";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_drawingFeatures.PaintingArea.Image.Save(saveFileDialog.FileName);
}
catch (Exception e)
{
MessageBox.Show("Could not save the file");
Logger logger = new Logger();
logger.Log(e);
}
}
}
示例13: CreateIToolObject
//.........这里部分代码省略.........
{
ITool tool = new RotateTool(drawingFeatures, RotateFlipType.Rotate180FlipNone);
return tool;
}
case "RotateRight270":
{
ITool tool = new RotateTool(drawingFeatures, RotateFlipType.Rotate270FlipNone);
return tool;
}
case "VerticalFlip":
{
ITool tool = new RotateTool(drawingFeatures, RotateFlipType.RotateNoneFlipY);
return tool;
}
case "HorizontalFlip":
{
ITool tool = new RotateTool(drawingFeatures, RotateFlipType.RotateNoneFlipX);
return tool;
}
case "HorizontalAndVerticalFlip":
{
ITool tool = new RotateTool(drawingFeatures, RotateFlipType.RotateNoneFlipXY);
return tool;
}
case "RoundLine":
{
ITool tool = new LineShapeTool(drawingFeatures, LineCap.Round);
return tool;
}
case "SquareLine":
{
ITool tool = new LineShapeTool(drawingFeatures, LineCap.Square);
return tool;
}
case "Circle":
{
ITool tool = new DrawingStyleTool(drawingFeatures,DrawingState.DrawCircle);
return tool;
}
case "Rectangle":
{
ITool tool = new DrawingStyleTool(drawingFeatures, DrawingState.DrawRectangle);
return tool;
}
case "FilledCircle":
{
ITool tool = new DrawingStyleTool(drawingFeatures, DrawingState.DrawFilledCircle);
return tool;
}
case "FilledRectangle":
{
ITool tool = new DrawingStyleTool(drawingFeatures, DrawingState.DrawFilledRectangle);
return tool;
}
case "Line":
{
ITool tool = new DrawingStyleTool(drawingFeatures, DrawingState.DrawLine);
return tool;
}
case "Pencil":
{
ITool tool = new DrawingStyleTool(drawingFeatures, DrawingState.DrawPencil);
return tool;
}
case "Eraser":
{
ITool tool = new EraserTool(drawingFeatures);
return tool;
}
case "FloodFill":
{
ITool tool = new DrawingStyleTool(drawingFeatures, DrawingState.FloodFill);
return tool;
}
default:
{
ITool tool = new NullTool();
Logger logger = new Logger();
logger.Log(new ArgumentException("ToolFactory - ToolName: " + toolName));
return tool;
}
}
}
示例14: SetShared
public void SetShared(ILogger logger, int num)
{
Logger = (Logger)logger;
if (num == 0)
{
_sharesNum = 1;
Logger.Log(LogLevel.Error, "Packet {0}, shares must be > 0!! Setting to 1", ToString());
}
Shared = true;
_sharesNum = num;
Write();
_buffer = new byte[Length];
byte[] underlyingBuffer = Writer.UnderlyingStream.GetBuffer();
try
{
Buffer.BlockCopy(underlyingBuffer, 0, _buffer, 0, Length);
}
catch (Exception e)
{
throw new Exception(String.Format("Writer {0}, Request {1} \r\n{2}", underlyingBuffer.Length, Length, e));
}
}
示例15: Main
static int Main(string[] args)
{
Console.WriteLine("");
if (args.Length != 2){
Console.WriteLine("Error: Number of argument is invalid !");
PrintHelper();
return (int)ExitCode.InvalidArguments;
}
string xmlFIlePath = args[0];
string logFIlePath = args[1];
if(!File.Exists(xmlFIlePath)){
Console.WriteLine("Error: Xml file argument doesn't exist !");
PrintHelper();
return (int)ExitCode.InvalidArguments;
}
if(!Directory.Exists(Path.GetDirectoryName(logFIlePath))){
Console.WriteLine("Error: The directory of the log file argument doesn't exist !");
PrintHelper();
return (int)ExitCode.InvalidArguments;
}
Logger logger=null;
try{
try{
logger = new Logger(args[1]);
}catch(Exception ex){
Console.WriteLine("Failed to create log file: " + ex.Message);
return (int)ExitCode.InvalidArguments;
}
RunnerPlan data;
try{
logger.Log("Parse xml file to get the compare plan (" + xmlFIlePath + ")");
data = RunnerPlan.ParseFromXml(xmlFIlePath);
logger.Log("\tCleanRegEx : " + data.CleanRegEx);
logger.Log("\tCompShape : " + data.CompShape);
logger.Log("\tCompStyle : " + data.CompStyle);
logger.Log("\tCompValue : " + data.CompValue);
}catch(Exception ex){
logger.Log("Failed to parse Xml file: " + ex.Message);
return (int)ExitCode.FailedToParsePlan;
}
Compare compare;
try{
compare = new Compare();
compare.InfoEvent += new InfoUpdateEventHandler(logger.Log);
compare.CompareFiles(data.FilesA, data.FilesB, data.CleanRegEx, data.ReportFolder, data.CompValue, data.CompStyle, data.CompStyle, true);
}catch(Exception ex){
logger.Log("Failed to compare files: " + ex.Message);
return (int)ExitCode.FailedToCompare;
}
logger.Log("End of comparison.");
return (int)ExitCode.Succeed;
}catch(Exception){
return (int)ExitCode.UnknownError;
}finally{
logger.Close();
}
}