Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7f914200
authored
Jan 17, 2025
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
回退 日志文件
1 parent
a0e33327
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
23 deletions
package-lock.json
utils/logger/LogCat.js
package-lock.json
View file @
7f91420
{
{
"name"
:
"gl
-
tape"
,
"name"
:
"gl
_
tape"
,
"lockfileVersion"
:
3
,
"lockfileVersion"
:
3
,
"requires"
:
true
,
"requires"
:
true
,
"packages"
:
{
"packages"
:
{
""
:
{
""
:
{
"name"
:
"gl_tape"
,
"dependencies"
:
{
"dependencies"
:
{
"dayjs"
:
"^1.11.11"
,
"dayjs"
:
"^1.11.11"
,
"eslint-config-prettier"
:
"^9.1.0"
,
"eslint-config-prettier"
:
"^9.1.0"
,
...
@@ -998,9 +999,9 @@
...
@@ -998,9 +999,9 @@
}
}
},
},
"node_modules/semver"
:
{
"node_modules/semver"
:
{
"version"
:
"5.
0.3
"
,
"version"
:
"5.
7.2
"
,
"resolved"
:
"https://registry.npmjs.org/semver/-/semver-5.
0.3
.tgz"
,
"resolved"
:
"https://registry.npmjs.org/semver/-/semver-5.
7.2
.tgz"
,
"integrity"
:
"sha512-
5OkOBiw69xqmxOFIXwXsiY1HlE+om8nNptg1ZIf95fzcnfgOv2fLm7pmmGbRJsjJIqPpW5Kwy4wpDBTz5wQlUw
=="
,
"integrity"
:
"sha512-
cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g
=="
,
"bin"
:
{
"bin"
:
{
"semver"
:
"bin/semver"
"semver"
:
"bin/semver"
}
}
...
@@ -1034,14 +1035,14 @@
...
@@ -1034,14 +1035,14 @@
}
}
},
},
"node_modules/spritesmith"
:
{
"node_modules/spritesmith"
:
{
"version"
:
"3.
4
.1"
,
"version"
:
"3.
5
.1"
,
"resolved"
:
"https://registry.npmjs.org/spritesmith/-/spritesmith-3.
4
.1.tgz"
,
"resolved"
:
"https://registry.npmjs.org/spritesmith/-/spritesmith-3.
5
.1.tgz"
,
"integrity"
:
"sha512-
NQZ8c7bZKbtqc0n0V+vVpurV72BwziOXw8AAU/nOdrjcjgCVoy+XUoopbrAYaNfJJgK730U98SB579+YtzfUJw
=="
,
"integrity"
:
"sha512-
FrzGx9cD5SkH3Kxuk24vJJLBYHLyDskUJ2t6DSWfWkCd8+yFQAfBGVE7F0IhOpKu+aq1CZ9rgXnpaa4luIQgGg
=="
,
"dependencies"
:
{
"dependencies"
:
{
"concat-stream"
:
"~1.5.1"
,
"concat-stream"
:
"~1.5.1"
,
"layout"
:
"~2.2.0"
,
"layout"
:
"~2.2.0"
,
"pixelsmith"
:
"^2.3.0"
,
"pixelsmith"
:
"^2.3.0"
,
"semver"
:
"~5.
0.3
"
,
"semver"
:
"~5.
7.2
"
,
"through2"
:
"~2.0.0"
"through2"
:
"~2.0.0"
},
},
"engines"
:
{
"engines"
:
{
...
...
utils/logger/LogCat.js
View file @
7f91420
import
{
getTime
}
from
'./util'
import
{
getTime
}
from
'./util'
import
{
serializeIfObject
}
from
'../utils'
import
{
serializeIfObject
}
from
'../utils'
class
LogCat
{
class
LogCat
{
// main = plus.android.runtimeMainActivity()
main
=
plus
.
android
.
runtimeMainActivity
()
// File = plus.android.importClass('java.io.File')
File
=
plus
.
android
.
importClass
(
'java.io.File'
)
// Environment = plus.android.importClass('android.os.Environment')
Environment
=
plus
.
android
.
importClass
(
'android.os.Environment'
)
// BufferedWriter = plus.android.importClass('java.io.BufferedWriter')
BufferedWriter
=
plus
.
android
.
importClass
(
'java.io.BufferedWriter'
)
// FileOutputStream = plus.android.importClass('java.io.FileOutputStream')
FileOutputStream
=
plus
.
android
.
importClass
(
'java.io.FileOutputStream'
)
// OutputStreamWriter = plus.android.importClass('java.io.OutputStreamWriter')
OutputStreamWriter
=
plus
.
android
.
importClass
(
'java.io.OutputStreamWriter'
)
// BufferedReader = plus.android.importClass('java.io.BufferedReader')
// BufferedReader = plus.android.importClass('java.io.BufferedReader')
// FileInputStream = plus.android.importClass('java.io.FileInputStream')
// FileInputStream = plus.android.importClass('java.io.FileInputStream')
// InputStreamReader = plus.android.importClass('java.io.InputStreamReader')
// InputStreamReader = plus.android.importClass('java.io.InputStreamReader')
LogPath
=
''
LogPath
=
''
constructor
(
folderName
=
'_zyzs_log'
)
{
constructor
(
folderName
=
'_zyzs_log'
)
{
//
if (this.Environment.MEDIA_MOUNTED || !this.Environment.isExternalStorageRemovable()) {
if
(
this
.
Environment
.
MEDIA_MOUNTED
||
!
this
.
Environment
.
isExternalStorageRemovable
())
{
//
this.LogPath = this.main.getExternalFilesDir(null).getPath() + folderName
this
.
LogPath
=
this
.
main
.
getExternalFilesDir
(
null
).
getPath
()
+
folderName
//
} else {
}
else
{
//
this.LogPath = this.main.getFilesDir().getPath() + folderName
this
.
LogPath
=
this
.
main
.
getFilesDir
().
getPath
()
+
folderName
//
}
}
//
console.log('日志文件存放路径->', this.LogPath)
console
.
log
(
'日志文件存放路径->'
,
this
.
LogPath
)
}
}
writeLog
(
tag
,
messages
)
{
writeLog
(
tag
,
messages
)
{
return
let
msg
=
serializeIfObject
(
messages
)
let
msg
=
serializeIfObject
(
messages
)
let
date
=
getTime
(
'YYYY-MM-DD'
)
let
date
=
getTime
(
'YYYY-MM-DD'
)
let
datetime
=
getTime
()
let
datetime
=
getTime
()
...
@@ -78,3 +75,83 @@ class LogCat {
...
@@ -78,3 +75,83 @@ class LogCat {
}
}
}
}
export
default
LogCat
export
default
LogCat
// import { getTime } from './util'
// import { serializeIfObject } from '../utils'
// class LogCat {
// // main = plus.android.runtimeMainActivity()
// // File = plus.android.importClass('java.io.File')
// // Environment = plus.android.importClass('android.os.Environment')
// // BufferedWriter = plus.android.importClass('java.io.BufferedWriter')
// // FileOutputStream = plus.android.importClass('java.io.FileOutputStream')
// // OutputStreamWriter = plus.android.importClass('java.io.OutputStreamWriter')
// // BufferedReader = plus.android.importClass('java.io.BufferedReader')
// // FileInputStream = plus.android.importClass('java.io.FileInputStream')
// // InputStreamReader = plus.android.importClass('java.io.InputStreamReader')
// LogPath = ''
// constructor(folderName = '_zyzs_log') {
// // if (this.Environment.MEDIA_MOUNTED || !this.Environment.isExternalStorageRemovable()) {
// // this.LogPath = this.main.getExternalFilesDir(null).getPath() + folderName
// // } else {
// // this.LogPath = this.main.getFilesDir().getPath() + folderName
// // }
// // console.log('日志文件存放路径->', this.LogPath)
// }
// writeLog(tag, messages) {
// return
// let msg = serializeIfObject(messages)
// let date = getTime('YYYY-MM-DD')
// let datetime = getTime()
// //文件名
// let fileName = this.LogPath + '/' + date + '.txt'
// //写入的内容
// let content = `${datetime} [${tag}] : ${msg}\n`
// console.log(content.replace(/\n/g, ''))
// let path = new this.File(this.LogPath)
// if (!path.exists()) {
// path.mkdirs() //创建父路径
// }
// let fos = null
// let bw = null
// try {
// fos = new this.FileOutputStream(fileName, true)
// bw = new this.BufferedWriter(new this.OutputStreamWriter(fos))
// //bw.write(log);
// bw.append(content)
// } catch (e) {
// console.log('e->', e)
// } finally {
// try {
// if (bw != null) {
// bw.close() //关闭缓冲流
// fos.close() //关闭文件输出流
// }
// } catch (closeEx) {
// console.log('closeEx->', closeEx)
// }
// }
// }
// // 删除日志
// removeLogFile(fileName) {
// let file = new this.File(fileName)
// let fos = new this.FileOutputStream(fileName, true)
// fos.close()
// file.delete()
// console.log('删除------' + fileName)
// }
// // 获取所有日志文件列表
// getLogFileList() {
// let file = new this.File(this.LogPath)
// let tempList = file.listFiles()
// if (!tempList || tempList.length === 0) return []
// const list = tempList.map(file => {
// return {
// name: file.getName(),
// path: file.getPath()
// }
// })
// return list
// }
// }
// export default LogCat
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment