首页 \ 问答 \ 子类化CocoaLumberJack(Subclassing CocoaLumberJack)

子类化CocoaLumberJack(Subclassing CocoaLumberJack)

我的应用程序中有一堆DDLogError语句。 我开始与朋友和家人一起测试应用程序。 每当其中一个测试应用程序遇到错误时,我希望能够自动返回日志。

Brute Force方法是在每个DDLogError语句下面添加一些DDLogError ,用于跟踪应用程序出错的事实并定期在后台上传这些用户的日志。

现在我已经将100多个这些语句分散在我的代码中,我宁愿只是全局更改DDLogError ,这样它就不会打印我在格式字符串中给出的内容,而且还会更新一个说明应用程序遇到错误情况的属性。

什么是最好的方法呢? 子类CocoaLumberJack类然后重写DDLogError方法?


I have a bunch of DDLogError statements in my app. I am starting to test the app with friends and family. Whenever one of these test apps hits an error, I want to be able to get back the logs automatically.

Brute Force way is to add something below each DDLogError statement, that keeps track of the fact that the app hit an error and periodically upload logs from such users in the background.

Now that I have 100s of these statements scattered all over my code, I would prefer to just change DDLogError globally so that it not prints what I give in the format string but also updates a property that says the app hit an error condition.

Whats the best way to do this? Subclass CocoaLumberJack class and then override the DDLogError method?


原文:https://stackoverflow.com/questions/34979461
更新时间:2022-02-04 19:02

最满意答案

在最简单的表单上,您只需要以正确的格式呈现它们。 这是一个简单的例子,可能需要一些微调......

在后面的代码上运行它,也许在PageLoad上运行

StringBuilder sb = new StringBuilder();

for(int i = 0 ; i < 3 ; i++)
 sb.AppendFormat("{3}{{name: '{0}',data: {1} }}", 
      Names[i], Data[i], 
       i>0 ? "," : "" // this is render the comma "," after the first line
  );    

ScriptData.Text = sb.ToString();

并使用Literal控件将它们放在页面上的脚本中

$(function () { 
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apples', 'Bananas', 'Oranges']
        },
        yAxis: {
            title: {
                text: 'Fruit eaten'
            }
        },
        series: [
        <asp:Literan id="ScriptData" Runat="server" EnableViewState="off" />
        ]
    });
});?

Here's what my solution for my problem, in case there would someone need this also.

Here's the JS function:

function LoadChart() {
    var Names = <%= this.javaSerial.Serialize(this.Names %>;
    var Data =  <%= this.javaSerial.Serialize(this.Data %>;

    var options = {
        chart: {
            renderTo: 'container',
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apple', 'Banana', 'Orange']
        },
        yAxis: {
            title: {
                text: 'fruit eaten'
            }
        },
        series: [{
            name: Names[0],
            data: [Data[0]]
        }]
    };

    for (var i=1; i<Names.Length; i++)
    {
        options.series.push({
            name: Names[i],
            data: [Data[i]]
        });
    }
    var chart = new Highcharts.Chart(options);
}

Here's some part of the code behind:

public JavaScriptSerializer javaSerial = new JavaScriptSerializer(); 
public string[] Names = new string[] { "Jane", "John", "Mike" };
public string[] Data = new string[] { "1,2,3", "2,4,6", "3,6,9" }

相关问答

更多
  • 您可以使用ClientScript.RegisterStartUpScript将JavaScript注入Page_Load的页面中。 以下是MSDN参考链接: http : //msdn.microsoft.com/en-us/library/asz8zsxy.aspx 以下是Page_Load中的代码: List tempString = new List(); tempString.Add("Hello"); tempString.Add("World"); ...
  • 如果一切工作正常,当你删除where子句,然后改变Where子句是这样的 string selectSQL = string.Format("SELECT lec FROM schedule WHERE dbo.schedule.day = {0} ", testDay); 我还会将字段名称更改为DayName之类的内容,或者如果day是保留字,请不要使用它..查看SQL链接中保留字的链接保留SQL字 if everything is working fine when you remove the ...
  • 您的debit_amount和credit_amount不是正确的数组。 var company = ['Ford', 'Toyota', 'Suzuki', 'Opel', 'BMW', 'Mercedes']; var debit_amount = [['AAA', 34.03], ['BBB', 27.01], ['CCC', 18.77], ['DDD', 11.01], ['EEE', 5.91], ['FFF', 3.27]]; var credi ...
  • 我已经解决了我的问题,但我使用了谷歌的可视化。 我使用了一个datalist并将javascript放在DataList上的标记内