Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
7fef8e12
Commit
7fef8e12
authored
2 years ago
by
Valentin Perrelle
Browse files
Options
Downloads
Patches
Plain Diff
[Dome] Use Dome.Debug
parent
e162e1cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ivette/src/dome/misc/system.ts
+37
-13
37 additions, 13 deletions
ivette/src/dome/misc/system.ts
ivette/src/dome/renderer/data/json.ts
+6
-4
6 additions, 4 deletions
ivette/src/dome/renderer/data/json.ts
ivette/src/dome/renderer/dome.tsx
+2
-29
2 additions, 29 deletions
ivette/src/dome/renderer/dome.tsx
with
45 additions
and
46 deletions
ivette/src/dome/misc/system.ts
+
37
−
13
View file @
7fef8e12
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
*/
*/
/* eslint-disable max-len */
/* eslint-disable max-len */
/* eslint-disable no-console */
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Evolved Spawn Process
// --- Evolved Spawn Process
...
@@ -38,6 +37,38 @@ import Exec from 'child_process';
...
@@ -38,6 +37,38 @@ import Exec from 'child_process';
import
fspath
from
'
path
'
;
import
fspath
from
'
path
'
;
import
fs
from
'
fs
'
;
import
fs
from
'
fs
'
;
// --------------------------------------------------------------------------
// --- Logging
// --------------------------------------------------------------------------
/** Development mode flag */
export
const
DEVEL
=
process
.
env
.
NODE_ENV
!==
'
production
'
;
export
class
Debug
{
moduleName
:
string
;
constructor
(
moduleName
:
string
)
{
this
.
moduleName
=
moduleName
;
}
/* eslint-disable no-console */
log
(...
args
:
unknown
[]):
void
{
if
(
DEVEL
)
console
.
log
(
`[
${
this
.
moduleName
}
]`
,
...
args
);
}
warn
(...
args
:
unknown
[]):
void
{
if
(
DEVEL
)
console
.
warn
(
`[
${
this
.
moduleName
}
]`
,
...
args
);
}
error
(...
args
:
unknown
[]):
void
{
if
(
DEVEL
)
console
.
error
(
`[
${
this
.
moduleName
}
]`
,
...
args
);
}
/* eslint-enable no-console */
}
const
D
=
new
Debug
(
'
dome
'
);
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Platform Specificities
// --- Platform Specificities
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -55,7 +86,7 @@ switch (process.platform) {
...
@@ -55,7 +86,7 @@ switch (process.platform) {
case
'
sunos
'
:
case
'
sunos
'
:
thePlatform
=
'
linux
'
;
break
;
thePlatform
=
'
linux
'
;
break
;
default
:
default
:
console
.
warn
(
`Unk
w
non '
${
process
.
platform
}
' (fallback to 'linux')`
);
D
.
warn
(
`Unkno
w
n '
${
process
.
platform
}
' (fallback to 'linux')`
);
thePlatform
=
'
linux
'
;
break
;
thePlatform
=
'
linux
'
;
break
;
}
}
...
@@ -72,13 +103,6 @@ switch (process.platform) {
...
@@ -72,13 +103,6 @@ switch (process.platform) {
*/
*/
export
const
platform
=
thePlatform
;
export
const
platform
=
thePlatform
;
// --------------------------------------------------------------------------
// --- Logging
// --------------------------------------------------------------------------
/** Development mode flag */
export
const
DEVEL
=
process
.
env
.
NODE_ENV
!==
'
production
'
;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- System Emitter
// --- System Emitter
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -107,7 +131,7 @@ export function atExit(callback: Callback): void {
...
@@ -107,7 +131,7 @@ export function atExit(callback: Callback): void {
export
function
doExit
():
void
{
export
function
doExit
():
void
{
exitJobs
.
forEach
((
fn
)
=>
{
exitJobs
.
forEach
((
fn
)
=>
{
try
{
fn
();
}
try
{
fn
();
}
catch
(
err
)
{
console
.
error
(
'
[Dome]
atExit:
'
,
err
);
}
catch
(
err
)
{
D
.
error
(
'
atExit:
'
,
err
);
}
});
});
exitJobs
.
length
=
0
;
exitJobs
.
length
=
0
;
}
}
...
@@ -399,7 +423,7 @@ async function rmDirRec(path: string): Promise<void> {
...
@@ -399,7 +423,7 @@ async function rmDirRec(path: string): Promise<void> {
return
;
return
;
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
DEVEL
)
console
.
warn
(
'
[Dome.rmDirRec]
'
,
err
);
D
.
warn
(
err
);
}
}
}
}
...
@@ -444,7 +468,7 @@ atExit(() => {
...
@@ -444,7 +468,7 @@ atExit(() => {
childprocess
.
forEach
((
process
,
pid
)
=>
{
childprocess
.
forEach
((
process
,
pid
)
=>
{
try
{
process
.
kill
();
}
try
{
process
.
kill
();
}
catch
(
err
)
{
catch
(
err
)
{
if
(
DEVEL
)
console
.
warn
(
'
[Dome.atExit]
killing process
'
,
pid
,
err
);
D
.
warn
(
'
killing process
'
,
pid
,
err
);
}
}
});
});
});
});
...
@@ -481,7 +505,7 @@ function pipeTee(std: Readable, fd: number): void {
...
@@ -481,7 +505,7 @@ function pipeTee(std: Readable, fd: number): void {
if
(
!
fd
)
return
;
if
(
!
fd
)
return
;
const
out
=
fs
.
createWriteStream
(
'
<ignored>
'
,
{
fd
,
encoding
:
'
utf-8
'
});
const
out
=
fs
.
createWriteStream
(
'
<ignored>
'
,
{
fd
,
encoding
:
'
utf-8
'
});
out
.
on
(
'
error
'
,
(
err
)
=>
{
out
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
warn
(
'
[Dome]
can not pipe:
'
,
err
);
D
.
warn
(
'
can not pipe:
'
,
err
);
std
.
unpipe
(
out
);
std
.
unpipe
(
out
);
});
});
std
.
pipe
(
out
);
std
.
pipe
(
out
);
...
...
This diff is collapsed.
Click to expand it.
ivette/src/dome/renderer/data/json.ts
+
6
−
4
View file @
7fef8e12
...
@@ -32,7 +32,9 @@
...
@@ -32,7 +32,9 @@
@module dome/data/json
@module dome/data/json
*/
*/
import
{
DEVEL
}
from
'
dome/system
'
;
import
{
Debug
}
from
'
dome/system
'
;
const
D
=
new
Debug
(
'
Dome.json
'
);
export
type
json
=
export
type
json
=
undefined
|
null
|
boolean
|
number
|
string
|
undefined
|
null
|
boolean
|
number
|
string
|
...
@@ -52,7 +54,7 @@ export function parse(text: string, noError = false): json {
...
@@ -52,7 +54,7 @@ export function parse(text: string, noError = false): json {
try
{
try
{
return
JSON
.
parse
(
text
);
return
JSON
.
parse
(
text
);
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
DEVEL
)
console
.
error
(
'
[Dome.json]
Invalid format:
'
,
err
);
D
.
error
(
'
Invalid format:
'
,
err
);
return
undefined
;
return
undefined
;
}
}
}
else
}
else
...
@@ -225,7 +227,7 @@ export function jCatch<A>(fn: Loose<A>, fallBack: A): Safe<A> {
...
@@ -225,7 +227,7 @@ export function jCatch<A>(fn: Loose<A>, fallBack: A): Safe<A> {
try
{
try
{
return
fn
(
js
)
??
fallBack
;
return
fn
(
js
)
??
fallBack
;
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
DEVEL
)
console
.
warn
(
'
[Dome.json]
'
,
err
);
D
.
warn
(
err
);
return
fallBack
;
return
fallBack
;
}
}
};
};
...
@@ -240,7 +242,7 @@ export function jTry<A>(fn: Loose<A>, defaultValue?: A): Loose<A> {
...
@@ -240,7 +242,7 @@ export function jTry<A>(fn: Loose<A>, defaultValue?: A): Loose<A> {
try
{
try
{
return
fn
(
js
)
??
defaultValue
;
return
fn
(
js
)
??
defaultValue
;
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
DEVEL
)
console
.
warn
(
'
[Dome.json]
'
,
err
);
D
.
warn
(
err
);
return
defaultValue
;
return
defaultValue
;
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
ivette/src/dome/renderer/dome.tsx
+
2
−
29
View file @
7fef8e12
...
@@ -75,8 +75,8 @@ function setContextAppNode(): HTMLElement | null {
...
@@ -75,8 +75,8 @@ function setContextAppNode(): HTMLElement | null {
// --- Helpers
// --- Helpers
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
/**
C
onfigured to be `'true'` when in development mode. */
/**
DEVEL is c
onfigured to be `'true'` when in development mode. */
export
const
{
DEVEL
}
=
System
;
export
const
{
DEVEL
,
Debug
}
=
System
;
export
type
PlatformKind
=
'
linux
'
|
'
macos
'
|
'
windows
'
;
export
type
PlatformKind
=
'
linux
'
|
'
macos
'
|
'
windows
'
;
...
@@ -815,30 +815,3 @@ export function useGlobalSettings<A extends Json.json>(
...
@@ -815,30 +815,3 @@ export function useGlobalSettings<A extends Json.json>(
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Pretty Printing (Browser Console)
// --------------------------------------------------------------------------
export
class
Debug
{
moduleName
:
string
;
constructor
(
moduleName
:
string
)
{
this
.
moduleName
=
moduleName
;
}
/* eslint-disable no-console */
log
(...
args
:
any
):
void
{
if
(
DEVEL
)
console
.
log
(
`[
${
this
.
moduleName
}
]`
,
...
args
);
}
warn
(...
args
:
any
):
void
{
if
(
DEVEL
)
console
.
warn
(
`[
${
this
.
moduleName
}
]`
,
...
args
);
}
error
(...
args
:
any
):
void
{
if
(
DEVEL
)
console
.
error
(
`[
${
this
.
moduleName
}
]`
,
...
args
);
}
/* eslint-enable no-console */
}
// --------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment