From 2ff041b2ff5f3f6a5dca248cf4ed36e1e0b378e0 Mon Sep 17 00:00:00 2001 From: ThunderMikey Date: Fri, 23 Mar 2018 10:04:03 +0000 Subject: Logger update (#166) * removing from ParserHelperFuncs * delete local logger in MarkdownGen * replace all local logger with globLog --- FMark/src/Common/Lexer/Lexer.fs | 3 ++- FMark/src/Common/Markalc/Expression.fs | 5 +++-- FMark/src/Common/Markalc/MarkalcShared.fs | 1 - FMark/src/Common/MarkdownGen/MarkdownGen.fs | 3 +-- FMark/src/Common/Parser/Parser.fs | 2 +- FMark/src/Common/Parser/ParserHelperFuncs.fs | 6 ++---- FMark/src/Common/Shared.fs | 1 - 7 files changed, 9 insertions(+), 12 deletions(-) (limited to 'FMark') diff --git a/FMark/src/Common/Lexer/Lexer.fs b/FMark/src/Common/Lexer/Lexer.fs index a7bd111..7cde51d 100644 --- a/FMark/src/Common/Lexer/Lexer.fs +++ b/FMark/src/Common/Lexer/Lexer.fs @@ -3,6 +3,7 @@ module Lexer open Types open Shared open LexerShared +open Logger type LexerState = | Normal @@ -74,7 +75,7 @@ let nextToken state s = | RegexMatch (literalString charList) (m, _, s), _ -> (LITERAL m, s), state | s, _ -> - sprintf "Unrecognised character: %A" s |> sharedLog.Warn None + sprintf "Unrecognised character: %A" s |> globLog.Warn None (toString s.[0] |> LITERAL, (sOnwards 1 s)), state /// Lexes a whole string and returns the result as a Token list diff --git a/FMark/src/Common/Markalc/Expression.fs b/FMark/src/Common/Markalc/Expression.fs index 3e35563..51f9653 100644 --- a/FMark/src/Common/Markalc/Expression.fs +++ b/FMark/src/Common/Markalc/Expression.fs @@ -3,6 +3,7 @@ module Expression open MarkalcShared open Types +open Logger (* SUPPORTED OPERATIONS: BinaryExpressions (in order of precedence): @@ -34,10 +35,10 @@ let parseExp toks = | RSBRA :: NUMBER(col) :: COMMA :: NUMBER(row) :: LSBRA :: after -> ((row,col) |> makeCellReference,after) |> Some | RSBRA :: NUMBER(row) :: EQUAL :: LITERAL("row") :: COMMA :: NUMBER(col) :: EQUAL :: LITERAL("col") :: LSBRA :: after - -> sprintf "Row:%A, Col:%A" row col |> logger.Debug None + -> sprintf "Row:%A, Col:%A" row col |> globLog.Debug None ((row,col) |> makeCellReference,after) |> Some | RSBRA :: NUMBER(col) :: EQUAL :: LITERAL("col") :: COMMA :: NUMBER(row) :: EQUAL :: LITERAL("row") :: LSBRA :: after - -> sprintf "Row:%A, Col:%A" row col |> logger.Debug None + -> sprintf "Row:%A, Col:%A" row col |> globLog.Debug None ((row,col) |> makeCellReference,after) |> Some | _ -> None let rec (|ExpressionList|_|) = function diff --git a/FMark/src/Common/Markalc/MarkalcShared.fs b/FMark/src/Common/Markalc/MarkalcShared.fs index a0f189a..6ffeab8 100644 --- a/FMark/src/Common/Markalc/MarkalcShared.fs +++ b/FMark/src/Common/Markalc/MarkalcShared.fs @@ -106,4 +106,3 @@ let simpleLex txt = let lexY (x,y,z) = x,y|>simpleLex,z let round (dp:int) (f:float) = System.Math.Round(f,dp) -let logger = Logger(LogLevel.INFO) \ No newline at end of file diff --git a/FMark/src/Common/MarkdownGen/MarkdownGen.fs b/FMark/src/Common/MarkdownGen/MarkdownGen.fs index 13008ef..3594a48 100644 --- a/FMark/src/Common/MarkdownGen/MarkdownGen.fs +++ b/FMark/src/Common/MarkdownGen/MarkdownGen.fs @@ -5,7 +5,6 @@ open Types open Shared open Logger -let logger = Logger(LogLevel.INFO) // return string surrounded by pat let surround pat str = @@ -99,7 +98,7 @@ let rec mdList list = | _,"" -> "" | true,_ -> sprintf "%s%i. %s\n" (makeTabs tab) pCount s - |> logPassN logger.Debug + |> logPassN globLog.Debug | false,_ -> sprintf "%s- %s\n" (makeTabs tab) s) |> retFold | NestedList(list) -> mdList list |> retFold diff --git a/FMark/src/Common/Parser/Parser.fs b/FMark/src/Common/Parser/Parser.fs index 507bf73..2e10969 100644 --- a/FMark/src/Common/Parser/Parser.fs +++ b/FMark/src/Common/Parser/Parser.fs @@ -16,7 +16,7 @@ let rec parseCode toks = parseCode toks' |> Result.map (fun (str, tks) -> mapTok tok + str, tks ) - | e -> sharedLog.Warn None (sprintf "%A" e) + | e -> globLog.Warn None (sprintf "%A" e) ("\\`", xOnwards 1 toks) |> Ok diff --git a/FMark/src/Common/Parser/ParserHelperFuncs.fs b/FMark/src/Common/Parser/ParserHelperFuncs.fs index 997af6d..0856a07 100644 --- a/FMark/src/Common/Parser/ParserHelperFuncs.fs +++ b/FMark/src/Common/Parser/ParserHelperFuncs.fs @@ -3,8 +3,6 @@ open Types open Shared open Logger -let logger = Logger(LogLevel.INFO) - let SPACE = " " let NOSTRING = "" @@ -386,12 +384,12 @@ let parseInLineElements2 refLst toks = match refs with | [] -> let msg = sprintf "[Reference: %A not found!]" refId - msg |> logger.Info (Some 200) |> ignore + msg |> globLog.Info (Some 200) |> ignore msg |> Error | [exactlyOne] -> exactlyOne |> Ok | moreThanOne -> let msg = sprintf "Reference: %A occurred more than once in reference list, take the first one." refId - msg |> logger.Info (Some 200) |> ignore + msg |> globLog.Info (Some 200) |> ignore List.head moreThanOne |> Ok /// find footnote in reference list, which contains both footnote and citation /// returns error msg if foot is not found diff --git a/FMark/src/Common/Shared.fs b/FMark/src/Common/Shared.fs index 6d20e19..e150c7f 100644 --- a/FMark/src/Common/Shared.fs +++ b/FMark/src/Common/Shared.fs @@ -64,4 +64,3 @@ let replaceChars pat (rep:string) s = Regex.Replace(s,pat,rep) let removeWhitespace (s:string) = s |> removeChars ["\n";"\t";"\r";" "] -let sharedLog = Logger(LogLevel.WARNING) \ No newline at end of file -- cgit