0

I'm writing a little game with SpriteKit using XCGLogger to write logs. The problem is that i can only see logs messages from the GameScene class in the log file, even when I use XCGLogger in other classes like maps, characters, etc.

I defined in appDelegate.swift file the path, log_level and write to tests messages. I used it in GameScene class and in other classes without any header redefinition or other setup. I only copied swift file and header file of XCGLogger library.

I used XCGLogger Version: 1.7 - LogLevel: Debug.

What i'm doing wrong ? It seems that i don't need to use a singleton to share same instance between classes cause log variable created in appDelegate class is a global variable.

Update : Instantiate code : AppDelegate.swift

let log = XCGLogger.defaultInstance()

// Configuración del sistema de Log XCGLogger
            //--------------------------------------------------
            let logPath : NSString = "/Users/memmaker6501/Desktop/CocoaGAME/OctoPussy/log/OctoPus_Log.txt".stringByExpandingTildeInPath
            log.setup(logLevel: .Debug, showLogLevel: true, showFileNames: true, showLineNumbers: true, writeToFile: logPath)

            log.verbose("A verbose message, usually useful when working on a specific problem")
            log.debug("A debug message")
            log.info("An info message, probably useful to power users looking in console.app")
            log.error("An error occurred, but it's recoverable, just info about what happened")
            log.severe("A severe error occurred, we are likely about to crash now")

GameScene.swift

Directly using the logging library --> log.debug("Entrada mouseDown")

Using the library in other classes, for example in Map.swift.

log.debug("Entrada generateTileGrid")

Thanks in advance.

Jorge Vega Sánchez
  • 7,430
  • 14
  • 55
  • 77
  • Can you post the code you're using to instantiate your XCGLogger object, and how you're using it in other classes? – Dave Wood Feb 22 '15 at 00:20
  • Post updated with the instantiate code – Jorge Vega Sánchez Feb 22 '15 at 12:17
  • If `let log = XCGLogger.defaultInstance()` is in the global scope of your `AppDelegate.swift`, then `log.debug("Entrada mouseDown")` should work in your other classes. Do you see messages in the debug console and just not in the log file? Or does nothing show up anywhere when you call `log.debug("message")`? – Dave Wood Feb 22 '15 at 14:40

0 Answers0