当前位置: 首页>>代码示例>>C#>>正文


C# ILoggerService.LogWarn方法代码示例

本文整理汇总了C#中ILoggerService.LogWarn方法的典型用法代码示例。如果您正苦于以下问题:C# ILoggerService.LogWarn方法的具体用法?C# ILoggerService.LogWarn怎么用?C# ILoggerService.LogWarn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILoggerService的用法示例。


在下文中一共展示了ILoggerService.LogWarn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main


//.........这里部分代码省略.........

                            count++;
                            SerDe.Write(s, buffer.Length);
                            SerDe.Write(s, buffer);
                        }

                        //TODO - complete the impl
                        logger.LogInfo("Count: " + count);

                        //if profiler:
                        //    profiler.profile(process)
                        //else:
                        //    process()

                        DateTime finish_time = DateTime.UtcNow;
                        const string format = "MM/dd/yyyy hh:mm:ss.fff tt";
                        logger.LogInfo(string.Format("bootTime: {0}, initTime: {1}, finish_time: {2}",
                            bootTime.ToString(format), initTime.ToString(format), finish_time.ToString(format)));
                        SerDe.Write(s, (int)SpecialLengths.TIMING_DATA);
                        SerDe.Write(s, ToUnixTime(bootTime));
                        SerDe.Write(s, ToUnixTime(initTime));
                        SerDe.Write(s, ToUnixTime(finish_time));

                        SerDe.Write(s, 0L); //shuffle.MemoryBytesSpilled
                        SerDe.Write(s, 0L); //shuffle.DiskBytesSpilled

                        commandProcessWatch.Stop();

                        // log statistics
                        inputEnumerator.LogStatistic();
                        logger.LogInfo(string.Format("func process time: {0}", funcProcessWatch.ElapsedMilliseconds));
                        logger.LogInfo(string.Format("command process time: {0}", commandProcessWatch.ElapsedMilliseconds));
                    }
                    else
                    {
                        logger.LogWarn("Nothing to execute :-(");
                    }

                    // Mark the beginning of the accumulators section of the output
                    SerDe.Write(s, (int)SpecialLengths.END_OF_DATA_SECTION);

                    SerDe.Write(s, Accumulator.accumulatorRegistry.Count);
                    foreach (var item in Accumulator.accumulatorRegistry)
                    {
                        var ms = new MemoryStream();
                        var value = item.Value.GetType().GetField("value", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(item.Value);
                        logger.LogInfo(string.Format("({0}, {1})", item.Key, value));
                        formatter.Serialize(ms, new KeyValuePair<int, dynamic>(item.Key, value));
                        byte[] buffer = ms.ToArray();
                        SerDe.Write(s, buffer.Length);
                        SerDe.Write(s, buffer);
                    }

                    int end = SerDe.ReadInt(s);

                    // check end of stream
                    if (end == (int)SpecialLengths.END_OF_STREAM)
                    {
                        SerDe.Write(s, (int)SpecialLengths.END_OF_STREAM);
                        logger.LogInfo("END_OF_STREAM: " + (int)SpecialLengths.END_OF_STREAM);
                    }
                    else
                    {
                        // write a different value to tell JVM to not reuse this worker
                        SerDe.Write(s, (int)SpecialLengths.END_OF_DATA_SECTION);
                        Environment.Exit(-1);
                    }
                    s.Flush();

                    // log bytes read and write
                    logger.LogInfo(string.Format("total read bytes: {0}", SerDe.totalReadNum));
                    logger.LogInfo(string.Format("total write bytes: {0}", SerDe.totalWriteNum));

                    // wait for server to complete, otherwise server gets 'connection reset' exception
                    // Use SerDe.ReadBytes() to detect java side has closed socket properly
                    // ReadBytes() will block until the socket is closed
                    SerDe.ReadBytes(s);
                }
                catch (Exception e)
                {
                    logger.LogError(e.ToString());
                    try
                    {
                        SerDe.Write(s, e.ToString());
                    }
                    catch (IOException)
                    {
                        // JVM close the socket
                    }
                    catch (Exception ex)
                    {
                        logger.LogError("CSharpWorker failed with exception:");
                        logger.LogException(ex);
                    }
                    Environment.Exit(-1);
                }
            }

            sock.Close();
        }
开发者ID:zhangf911,项目名称:SparkCLR,代码行数:101,代码来源:Worker.cs

示例2: Main


//.........这里部分代码省略.........
                            }
                            else
                            {
                                try
                                {
                                    var ms = new MemoryStream();
                                    formatter.Serialize(ms, message);
                                    buffer = ms.ToArray();
                                }
                                catch (Exception)
                                {
                                    logger.LogError(string.Format("{0} : {1}", message.GetType().Name, message.GetType().FullName));
                                    throw;
                                }
                            }

                            count++;
                            SerDe.Write(s, buffer.Length);
                            SerDe.Write(s, buffer);
                        }

                        //TODO - complete the impl
                        logger.LogInfo("Count: " + count);

                        //if profiler:
                        //    profiler.profile(process)
                        //else:
                        //    process()

                        DateTime finish_time = DateTime.UtcNow;
                        string format = "MM/dd/yyyy hh:mm:ss.fff tt";
                        logger.LogInfo(string.Format("bootTime: {0}, initTime: {1}, finish_time: {2}",
                            bootTime.ToString(format), initTime.ToString(format), finish_time.ToString(format)));
                        SerDe.Write(s, (int)SpecialLengths.TIMING_DATA);
                        SerDe.Write(s, ToUnixTime(bootTime));
                        SerDe.Write(s, ToUnixTime(initTime));
                        SerDe.Write(s, ToUnixTime(finish_time));

                        SerDe.Write(s, 0L); //shuffle.MemoryBytesSpilled
                        SerDe.Write(s, 0L); //shuffle.DiskBytesSpilled
                    }
                    else
                    {
                        logger.LogWarn("Nothing to execute :-(");
                    }

                    // Mark the beginning of the accumulators section of the output
                    SerDe.Write(s, (int)SpecialLengths.END_OF_DATA_SECTION);

                    SerDe.Write(s, Accumulator.accumulatorRegistry.Count);
                    foreach (var item in Accumulator.accumulatorRegistry)
                    {
                        var ms = new MemoryStream();
                        var value = item.Value.GetType().GetField("value", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(item.Value);
                        logger.LogInfo(string.Format("({0}, {1})", item.Key, value));
                        formatter.Serialize(ms, new KeyValuePair<int, dynamic>(item.Key, value));
                        byte[] buffer = ms.ToArray();
                        SerDe.Write(s, buffer.Length);
                        SerDe.Write(s, buffer);
                    }

                    int end = SerDe.ReadInt(s);

                    // check end of stream
                    if (end == (int)SpecialLengths.END_OF_DATA_SECTION || end == (int)SpecialLengths.END_OF_STREAM)
                    {
                        SerDe.Write(s, (int)SpecialLengths.END_OF_STREAM);
                        logger.LogInfo("END_OF_STREAM: " + (int)SpecialLengths.END_OF_STREAM);
                    }
                    else
                    {
                        // write a different value to tell JVM to not reuse this worker
                        SerDe.Write(s, (int)SpecialLengths.END_OF_DATA_SECTION);
                        Environment.Exit(-1);
                    }
                    s.Flush();
                    System.Threading.Thread.Sleep(1000); //TODO - not sure if this is really needed
                }
                catch (Exception e)
                {
                    logger.LogError(e.ToString());
                    try
                    {
                        SerDe.Write(s, e.ToString());
                    }
                    catch (IOException)
                    {
                        // JVM close the socket
                    }
                    catch (Exception ex)
                    {
                        logger.LogError("CSharpWorker failed with exception:");
                        logger.LogException(ex);
                    }
                    Environment.Exit(-1);
                }
            }

            sock.Close();
        }
开发者ID:jinyeqing,项目名称:SparkCLR,代码行数:101,代码来源:Worker.cs


注:本文中的ILoggerService.LogWarn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。