QueueFileLogStore.java
3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package com.crashlytics.android.core;
import io.fabric.sdk.android.Fabric;
import io.fabric.sdk.android.Logger;
import io.fabric.sdk.android.services.common.CommonUtils;
import io.fabric.sdk.android.services.common.QueueFile;
import io.fabric.sdk.android.services.common.QueueFile.ElementReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
class QueueFileLogStore
implements FileLogStore
{
private QueueFile logFile;
private final int maxLogSize;
private final File workingFile;
public QueueFileLogStore(File paramFile, int paramInt)
{
this.workingFile = paramFile;
this.maxLogSize = paramInt;
}
private void doWriteToLog(long paramLong, String paramString)
{
if (this.logFile == null) {}
for (;;)
{
return;
if (paramString == null)
{
paramString = "null";
try
{
for (;;)
{
int i = this.maxLogSize / 4;
String str = paramString;
if (paramString.length() > i) {
str = "..." + paramString.substring(paramString.length() - i);
}
paramString = str.replaceAll("\r", " ").replaceAll("\n", " ");
paramString = String.format(Locale.US, "%d %s%n", new Object[] { Long.valueOf(paramLong), paramString }).getBytes("UTF-8");
this.logFile.add(paramString);
while ((!this.logFile.isEmpty()) && (this.logFile.usedBytes() > this.maxLogSize)) {
this.logFile.remove();
}
}
}
catch (IOException paramString)
{
Fabric.getLogger().e("CrashlyticsCore", "There was a problem writing to the Crashlytics log.", paramString);
return;
}
}
}
}
private void openLogFile()
{
if (this.logFile == null) {}
try
{
this.logFile = new QueueFile(this.workingFile);
return;
}
catch (IOException localIOException)
{
Fabric.getLogger().e("CrashlyticsCore", "Could not open log file: " + this.workingFile, localIOException);
}
}
public void closeLogFile()
{
CommonUtils.closeOrLog(this.logFile, "There was a problem closing the Crashlytics log file.");
this.logFile = null;
}
public void deleteLogFile()
{
closeLogFile();
this.workingFile.delete();
}
public ByteString getLogAsByteString()
{
if (!this.workingFile.exists()) {}
do
{
return null;
openLogFile();
} while (this.logFile == null);
final int[] arrayOfInt = new int[1];
arrayOfInt[0] = 0;
final byte[] arrayOfByte = new byte[this.logFile.usedBytes()];
try
{
this.logFile.forEach(new QueueFile.ElementReader()
{
public void read(InputStream paramAnonymousInputStream, int paramAnonymousInt)
throws IOException
{
try
{
paramAnonymousInputStream.read(arrayOfByte, arrayOfInt[0], paramAnonymousInt);
int[] arrayOfInt = arrayOfInt;
arrayOfInt[0] += paramAnonymousInt;
return;
}
finally
{
paramAnonymousInputStream.close();
}
}
});
return ByteString.copyFrom(arrayOfByte, 0, arrayOfInt[0]);
}
catch (IOException localIOException)
{
for (;;)
{
Fabric.getLogger().e("CrashlyticsCore", "A problem occurred while reading the Crashlytics log file.", localIOException);
}
}
}
public void writeToLog(long paramLong, String paramString)
{
openLogFile();
doWriteToLog(paramLong, paramString);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/crashlytics/android/core/QueueFileLogStore.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/