-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86a1adc
commit b7ae891
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createLogger, Logger } from 'lovely-logs'; | ||
import type { ValidateError } from '@markdoc/markdoc'; | ||
|
||
createLogger({ | ||
platform: 'console', | ||
timestampEnabled: false, | ||
}); | ||
|
||
export function log_validation_error( | ||
validate_error: ValidateError, | ||
filename: string, | ||
) { | ||
const { error } = validate_error; | ||
const prefix = `[svelte-markdoc-preprocess] ${filename}:${validate_error.lines.join( | ||
':', | ||
)} (${error.id}) `; | ||
|
||
switch (error.level) { | ||
case 'debug': | ||
case 'info': | ||
return Logger.info(prefix, error.message); | ||
case 'warning': | ||
return Logger.warn(prefix, error.message); | ||
case 'error': | ||
case 'critical': | ||
return Logger.error(prefix, error.message); | ||
} | ||
} | ||
|
||
export function log_error(message: string) { | ||
Logger.error(`[svelte-markdoc-preprocess]: ${message}`); | ||
} | ||
export function log_warning(message: string) { | ||
Logger.warn(`[svelte-markdoc-preprocess]: ${message}`); | ||
} | ||
export function log_info(message: string) { | ||
Logger.info(`[svelte-markdoc-preprocess]: ${message}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters